Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9a3f441d832d8c728201d1a566807f7add2a41f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************************************************
 * Copyright (c) 2004, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel;

import org.eclipse.wst.ws.internal.datamodel.BasicElement;
import org.eclipse.wst.ws.internal.datamodel.Model;

public class WsilCommonElement extends BasicElement
{
  private String baseWsilURL;
  private String relativeURIBase;

  public WsilCommonElement(String name, Model model)
  {
    super(name, model);
  }
  
  public String getBaseWsilURL()
  {
    return baseWsilURL;
  }
  
  public void setBaseWsilURL(String baseWsilURL)
  {
    this.baseWsilURL = baseWsilURL;
  }
  
  private final char FWD_SLASH = '/';
  private final char BWD_SLASH = '\\';
  private final char PROTOCOL_INDICATOR = ':';
  
  public String makeAbsolute(String uri)
  {
    if (baseWsilURL != null && uri != null && uri.indexOf(PROTOCOL_INDICATOR) == -1)
    {
      if (relativeURIBase == null)
      {
        relativeURIBase = baseWsilURL.replace(BWD_SLASH, FWD_SLASH);
        int index = relativeURIBase.lastIndexOf(FWD_SLASH);
        relativeURIBase = baseWsilURL.substring(0, index + 1);
      }
      StringBuffer sb = new StringBuffer(relativeURIBase);
      sb.append(uri);
      return sb.toString();
    }
    return uri;
  }
}

Back to the top