/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2001, 2002,2004 The Apache Software Foundation.
*
* Licensed 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
*
*
* 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.
*/
/**
* A class used to hold the internal schema grammar set for the current instance
*
* @xerces.internal
*
* @author Sandy Gao, IBM
* @version $Id: XSGrammarBucket.java,v 1.7 2010-11-01 04:39:55 joehw Exp $
*/
public class XSGrammarBucket {
// Data
/**
* Hashtable that maps between Namespace and a Grammar
*/
/**
* Get the schema grammar for the specified namespace
*
* @param namespace
* @return SchemaGrammar associated with the namespace
*/
return fNoNSGrammar;
}
/**
* Put a schema grammar into the registry
* This method is for internal use only: it assumes that a grammar with
* the same target namespace is not already in the bucket.
*
* @param grammar the grammar to put in the registry
*/
else
}
/**
* put a schema grammar and any grammars imported by it (directly or
* inderectly) into the registry. when a grammar with the same target
* namespace is already in the bucket, and different from the one being
* added, it's an error, and no grammar will be added into the bucket.
*
* @param grammar the grammar to put in the registry
* @param deep whether to add imported grammars
* @return whether the process succeeded
*/
// whether there is one with the same tns
// if the one we have is different from the one passed, it's an error
}
// not deep import, then just add this one grammar
if (!deep) {
return true;
}
// get all imported grammars, and make a copy of the Vector, so that
// we can recursively process the grammars, and add distinct ones
// to the same vector
if (currGrammars == null) {
return true;
}
// for all (recursively) imported grammars
// get the grammar
// check whether the bucket has one with the same tns
// we need to add grammars imported by sg1 too
// for all grammars imported by sg2, but not in the vector
// we add them to the vector
}
}
// we found one with the same target namespace
// if the two grammars are not the same object, then it's an error
return false;
}
}
// now we have all imported grammars stored in the vector. add them
return true;
}
/**
* put a schema grammar and any grammars imported by it (directly or
* inderectly) into the registry. when a grammar with the same target
* namespace is already in the bucket, and different from the one being
* added, no grammar will be added into the bucket.
*
* @param grammar the grammar to put in the registry
* @param deep whether to add imported grammars
* @param ignoreConflict whether to ignore grammars that already exist in the grammar
* bucket or not - including 'grammar' parameter.
* @return whether the process succeeded
*/
if (!ignoreConflict) {
}
// if grammar already exist in the bucket, we ignore the request
}
// not adding the imported grammars
if (!deep) {
return true;
}
// get all imported grammars, and make a copy of the Vector, so that
// we can recursively process the grammars, and add distinct ones
// to the same vector
if (currGrammars == null) {
return true;
}
// for all (recursively) imported grammars
// get the grammar
// check whether the bucket has one with the same tns
// we need to add grammars imported by sg1 too
// for all grammars imported by sg2, but not in the vector
// we add them to the vector
}
}
// we found one with the same target namespace, ignore it
else {
}
}
// now we have all imported grammars stored in the vector. add them
}
return true;
}
/**
* get all grammars in the registry
*
* @return an array of SchemaGrammars.
*/
// get the number of grammars
// get grammars with target namespace
int i = 0;
}
// add the grammar without target namespace, if any
if (fNoNSGrammar != null)
return grammars;
}
/**
* Clear the registry.
* REVISIT: update to use another XSGrammarBucket
*/
public void reset() {
fNoNSGrammar = null;
}
} // class XSGrammarBucket