/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
*
* @author K.Venugopal SUN Microsystems
* @author Neeraj Bajaj SUN Microsystems
* @author Andy Clark, IBM
*
*/
public class XMLEntityStorage {
/** Property identifier: error reporter. */
/** Feature identifier: warn on duplicate EntityDef */
/** warn on duplicate Entity declaration.
*/
protected boolean fWarnDuplicateEntityDef;
/** Entities. */
/**
* Error reporter. This property identifier is:
*/
/* To keep track whether an entity is declared in external or internal subset*/
protected boolean fInExternalSubset = false;
/** Creates a new instance of XMLEntityStorage */
}
/** Creates a new instance of XMLEntityStorage */
/*public XMLEntityStorage(Entity.ScannedEntity currentEntity) {
fCurrentEntity = currentEntity ;*/
}
fErrorReporter = (XMLErrorReporter)propertyManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY);
}
public void reset(){
}
/**
* Resets the component. The component can query the component manager
* about any features and properties that affect the operation of the
* component.
*
* @param componentManager The component manager.
*
* @throws SAXException Thrown by component on initialization error.
* For example, if a feature or property is
* required for the operation of the component, the
* component manager may throw a
* SAXNotRecognizedException or a
* SAXNotSupportedException.
*/
throws XMLConfigurationException {
// xerces features
} // reset(XMLComponentManager)
/**
* Returns entity declaration.
*
* @param name The name of the entity.
*
* @see SymbolTable
*/
} // getEntity(String)
public boolean hasEntities() {
} // getEntity(String)
public int getEntitySize() {
} // getEntity(String)
}
/**
* Adds an internal entity declaration.
* <p>
* <strong>Note:</strong> This method ignores subsequent entity
* declarations.
* <p>
* <strong>Note:</strong> The name should be a unique symbol. The
* SymbolTable can be used for this purpose.
*
* @param name The name of the entity.
* @param text The text of the entity.
*
* @see SymbolTable
*/
}
else{
"MSG_DUPLICATE_ENTITY_DEFINITION",
}
}
} // addInternalEntity(String,String)
/**
* Adds an external entity declaration.
* <p>
* <strong>Note:</strong> This method ignores subsequent entity
* declarations.
* <p>
* <strong>Note:</strong> The name should be a unique symbol. The
* SymbolTable can be used for this purpose.
*
* @param name The name of the entity.
* @param publicId The public identifier of the entity.
* @param literalSystemId The system identifier of the entity.
* @param baseSystemId The base system identifier of the entity.
* This is the system identifier of the entity
* where <em>the entity being added</em> and
* is used to expand the system identifier when
* the system identifier is a relative URI.
* When null the system identifier of the first
* external entity on the stack is used instead.
*
* @see SymbolTable
*/
if (baseSystemId == null) {
// search for the first external entity on the stack
//xxx commenting the 'size' variable..
/**
* int size = fEntityStack.size();
* if (size == 0 && fCurrentEntity != null && fCurrentEntity.entityLocation != null) {
* baseSystemId = fCurrentEntity.entityLocation.getExpandedSystemId();
* }
*/
//xxx we need to have information about the current entity.
}
/**
* for (int i = size - 1; i >= 0 ; i--) {
* ScannedEntity externalEntity =
* (ScannedEntity)fEntityStack.elementAt(i);
* if (externalEntity.entityLocation != null && externalEntity.entityLocation.getExpandedSystemId() != null) {
* baseSystemId = externalEntity.entityLocation.getExpandedSystemId();
* break;
* }
* }
*/
}
//TODO :: Forced to pass true above remove it.
//(fCurrentEntity == null) ? fasle : fCurrentEntity.isEntityDeclInExternalSubset());
// null, fCurrentEntity.isEntityDeclInExternalSubset());
}
else{
"MSG_DUPLICATE_ENTITY_DEFINITION",
}
}
} // addExternalEntity(String,String,String,String)
/**
* Checks whether an entity given by name is external.
*
* @param entityName The name of the entity to check.
* @returns True if the entity is external, false otherwise
* (including when the entity is not declared).
*/
return false;
}
return entity.isExternal();
}
/**
* Checks whether the declaration of an entity given by name is
* // in the external subset.
*
* @param entityName The name of the entity to check.
* @returns True if the entity was declared in the external subset, false otherwise
* (including when the entity is not declared).
*/
return false;
}
return entity.isEntityDeclInExternalSubset();
}
/**
* Adds an unparsed entity declaration.
* <p>
* <strong>Note:</strong> This method ignores subsequent entity
* declarations.
* <p>
* <strong>Note:</strong> The name should be a unique symbol. The
* SymbolTable can be used for this purpose.
*
* @param name The name of the entity.
* @param publicId The public identifier of the entity.
* @param systemId The system identifier of the entity.
* @param notation The name of the notation.
*
* @see SymbolTable
*/
Entity entity = new Entity.ExternalEntity(name, new XMLResourceIdentifierImpl(publicId, systemId, baseSystemId, null), notation, fInExternalSubset);
// (fCurrentEntity == null) ? fasle : fCurrentEntity.isEntityDeclInExternalSubset());
// fCurrentEntity.isEntityDeclInExternalSubset());
}
else{
"MSG_DUPLICATE_ENTITY_DEFINITION",
}
}
} // addUnparsedEntity(String,String,String,String)
/**
* Checks whether an entity given by name is unparsed.
*
* @param entityName The name of the entity to check.
* @returns True if the entity is unparsed, false otherwise
* (including when the entity is not declared).
*/
return false;
}
return entity.isUnparsed();
}
/**
* Checks whether an entity given by name is declared.
*
* @param entityName The name of the entity to check.
* @returns True if the entity is declared, false otherwise.
*/
}
/**
* Expands a system id and returns the system id as a URI, if
* it can be expanded. A return value of null means that the
* identifier is already expanded. An exception thrown
* indicates a failure to expand the id.
*
* @param systemId The systemId to be expanded.
*
* @return Returns the URI string representing the expanded system
* identifier. A null value indicates that the given
* system identifier is already expanded.
*
*/
} // expandSystemId(String):String
// current value of the "user.dir" property
// escaped value of the current "user.dir" property
// which ASCII characters need to be escaped
// the first hex character if a character needs to be escaped
// the second hex character if a character needs to be escaped
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
// initialize the above 3 arrays
static {
for (int i = 0; i <= 0x1f; i++) {
gNeedEscaping[i] = true;
}
gNeedEscaping[0x7f] = true;
'|', '\\', '^', '~', '[', ']', '`'};
char ch;
for (int i = 0; i < len; i++) {
gNeedEscaping[ch] = true;
}
}
// To escape the "user.dir" system property, by using %HH to represent
// special ASCII characters: 0x00~0x1F, 0x7F, ' ', '<', '>', '#', '%'
// and '"'. It's a static method, so needs to be synchronized.
// this method looks heavy, but since the system property isn't expected
// to change often, so in most cases, we only need to return the string
// that was escaped before.
// According to the URI spec, non-ASCII characters (whose value >= 128)
// need to be escaped too.
// REVISIT: don't know how to escape non-ASCII characters, especially
// which encoding to use. Leave them for now.
// get the user.dir property
try {
}
catch (SecurityException se) {
}
// return empty string if property value is empty string.
return "";
// compute the new escaped value if the new property value doesn't
// match the previous one
return gEscapedUserDir;
}
// record the new value as the global property value
// change C:/blah to /C:/blah
}
}
// for each character in the path
int i = 0;
for (; i < len; i++) {
// if it's not an ASCII character, break here, and use UTF-8 encoding
if (ch >= 128)
break;
if (gNeedEscaping[ch]) {
// record the fact that it's escaped
}
else {
}
}
// we saw some non-ascii character
if (i < len) {
// get UTF-8 bytes for the remaining sub-string
byte b;
try {
// should never happen
return userDir;
}
// for each byte
for (i = 0; i < len; i++) {
b = bytes[i];
// for non-ascii character: make it positive, then escape
if (b < 0) {
ch = b + 256;
}
else if (gNeedEscaping[b]) {
}
else {
}
}
}
return gEscapedUserDir;
}
/**
* Expands a system id and returns the system id as a URI, if
* it can be expanded. A return value of null means that the
* identifier is already expanded. An exception thrown
* indicates a failure to expand the id.
*
* @param systemId The systemId to be expanded.
*
* @return Returns the URI string representing the expanded system
* identifier. A null value indicates that the given
* system identifier is already expanded.
*
*/
// check for bad parameters id
return systemId;
}
// if id already expanded, return
try {
return systemId;
} catch (URI.MalformedURIException e) {
// continue on...
}
// normalize id
// normalize base
try {
}
else {
try {
}
catch (URI.MalformedURIException e) {
// for xml schemas we might have baseURI with
// a specified drive
}
else {
}
}
}
// expand id
}
catch (Exception e) {
// let it go through
}
return systemId;
}
} // expandSystemId(String,String):String
//
// Protected static methods
//
/**
* Fixes a platform dependent filename to standard URI form.
*
* @param str The string to fix.
*
* @return Returns the fixed URI string.
*/
// handle platform dependent strings
// Windows fix
// change "C:blah" to "/C:blah"
if (ch1 == ':') {
}
}
// change "//blah" to "file://blah"
}
}
// done
return str;
} // fixURI(String):String
// indicate start of external subset
public void startExternalSubset() {
fInExternalSubset = true;
}
public void endExternalSubset() {
fInExternalSubset = false;
}
}