|
|
|
|
|
|
|
*/ |
|
/* |
|
* Licensed to the Apache Software Foundation (ASF) under one or more |
|
* contributor license agreements. See the NOTICE file distributed with |
|
* this work for additional information regarding copyright ownership. |
|
* The ASF licenses this file to You under the Apache License, Version 2.0 |
|
* (the "License"); you may not use this file except in compliance with |
|
* the License. You may obtain a copy of the License at |
|
* |
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
* |
|
* Unless required by applicable law or agreed to in writing, software |
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
* See the License for the specific language governing permissions and |
|
* limitations under the License. |
|
*/ |
|
|
|
package com.sun.org.apache.xerces.internal.impl.xs; |
|
|
|
import com.sun.org.apache.xerces.internal.util.NamespaceSupport; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public class SchemaNamespaceSupport |
|
extends NamespaceSupport { |
|
|
|
public SchemaNamespaceSupport () { |
|
super(); |
|
} // constructor |
|
|
|
|
|
public SchemaNamespaceSupport(SchemaNamespaceSupport nSupport) { |
|
fNamespaceSize = nSupport.fNamespaceSize; |
|
if (fNamespace.length < fNamespaceSize) |
|
fNamespace = new String[fNamespaceSize]; |
|
System.arraycopy(nSupport.fNamespace, 0, fNamespace, 0, fNamespaceSize); |
|
fCurrentContext = nSupport.fCurrentContext; |
|
if (fContext.length <= fCurrentContext) |
|
fContext = new int[fCurrentContext+1]; |
|
System.arraycopy(nSupport.fContext, 0, fContext, 0, fCurrentContext+1); |
|
} // end constructor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public void setEffectiveContext (String [] namespaceDecls) { |
|
if(namespaceDecls == null || namespaceDecls.length == 0) return; |
|
pushContext(); |
|
int newSize = fNamespaceSize + namespaceDecls.length; |
|
if (fNamespace.length < newSize) { |
|
|
|
String[] tempNSArray = new String[newSize]; |
|
System.arraycopy(fNamespace, 0, tempNSArray, 0, fNamespace.length); |
|
fNamespace = tempNSArray; |
|
} |
|
System.arraycopy(namespaceDecls, 0, fNamespace, fNamespaceSize, |
|
namespaceDecls.length); |
|
fNamespaceSize = newSize; |
|
} // setEffectiveContext(String):void |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
public String [] getEffectiveLocalContext() { |
|
// the trick here is to recognize that all local contexts |
|
// happen to start at fContext[3]. |
|
// context 1: empty |
|
// context 2: decls for xml and xmlns; |
|
|
|
String[] returnVal = null; |
|
if (fCurrentContext >= 3) { |
|
int bottomLocalContext = fContext[3]; |
|
int copyCount = fNamespaceSize - bottomLocalContext; |
|
if (copyCount > 0) { |
|
returnVal = new String[copyCount]; |
|
System.arraycopy(fNamespace, bottomLocalContext, returnVal, 0, |
|
copyCount); |
|
} |
|
} |
|
return returnVal; |
|
} // getEffectiveLocalContext():String |
|
|
|
// This method removes from this object all the namespaces |
|
|
|
public void makeGlobal() { |
|
if (fCurrentContext >= 3) { |
|
fCurrentContext = 3; |
|
fNamespaceSize = fContext[3]; |
|
} |
|
} // makeGlobal |
|
} // class NamespaceSupport |