com.sun.tools.ws.wsdl.framework.WSDLLocation Maven / Gradle / Ivy
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package com.sun.tools.ws.wsdl.framework;
/**
*
* Maintains wsdl:location context. This is used with
* TWSDLParserContextImpl, where one each WSDL being imported its location is pushed.
*
* @author WS Development Team
*/
public class WSDLLocation {
WSDLLocation() {
reset();
}
public void push() {
int max = contexts.length;
idPos++;
if (idPos >= max) {
LocationContext newContexts[] = new LocationContext[max * 2];
System.arraycopy(contexts, 0, newContexts, 0, max);
contexts = newContexts;
}
currentContext = contexts[idPos];
if (currentContext == null) {
contexts[idPos] = currentContext = new LocationContext();
}
}
public void pop() {
idPos--;
if (idPos >= 0) {
currentContext = contexts[idPos];
}
}
public final void reset() {
contexts = new LocationContext[32];
idPos = 0;
contexts[idPos] = currentContext = new LocationContext();
}
public String getLocation() {
return currentContext.getLocation();
}
public void setLocation(String loc) {
currentContext.setLocation(loc);
}
private LocationContext[] contexts;
private int idPos;
private LocationContext currentContext;
// LocationContext - inner class
private static class LocationContext {
void setLocation(String loc) {
location = loc;
}
String getLocation() {
return location;
}
private String location;
}
}