/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
*/
/**
* @author Arun Yadav, Sun Microsystem
*/
// recognized features and properties
/** Property identifier: error handler. */
/** Property identifier: grammar pool . */
/** Property identifier: grammar pool . */
/** Recognized features. */
};
/** Feature defaults. */
};
/** Recognized properties. */
/** Property defaults. */
// Data
//protected String fPointerSchema;
// The current element depth.
// This is used to access the appropriate level of the following stacks.
private int fDepth;
// The depth of the first element to actually be part of the result infoset.
// This will normally be 1, but it could be larger when the top-level item
// is an include, and processing goes to the fallback.
private int fRootDepth;
// this value must be at least 1
// Used to ensure that fallbacks are always children of include elements,
// and that include elements are never children of other include elements.
// An index contains true if the ancestor of the current element which resides
// at that depth was an include element.
// Ensures that only one fallback element can be at a single depth.
// An index contains true if we have seen any fallback elements at that depth,
// and it is only reset to false when the end tag of the parent is encountered.
// The state of the processor at each given depth.
boolean skip = false;
// Constructors
public XPointerElementHandler() {
fDepth = 0;
fRootDepth = 0;
fSawFallback[fDepth] = false;
fSawInclude[fDepth] = false;
fSchemaName="element";
}
// START OF IMPLEMENTATION OF XMLComponent methods //////
public void reset(){
elemCount =0;
fElementCount =0;
fCurrentToken =0;
includeElement = false;
foundElement = null;
skip = false;
fSubResourceIdentified=false;
}
throws XNIException {
elemCount =0;
fDepth = 0;
fRootDepth = 0;
foundElement = null;
includeElement = false;
skip = false;
fSubResourceIdentified=false;
try {
}
catch (XMLConfigurationException e) {
}
try {
}
catch (XMLConfigurationException e) {
fGrammarPool = null;
}
try {
}
catch (XMLConfigurationException e) {
}
fSettings = new ParserConfigurationSettings();
while (xercesFeatures.hasMoreElements()) {
try {
}
catch (XMLConfigurationException e) {
// componentManager doesn't support this feature,
// so we won't worry about it
}
}
/* try{
dtdValidator = (XMLDTDValidator)componentManager.getProperty( Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY);
}Catch(Exception ex){
ex.printStackTrace();
}*/
} // reset(XMLComponentManager)
/**
* Returns a list of feature identifiers that are recognized by
* this component. This method may return null if no features
* are recognized by this component.
*/
return RECOGNIZED_FEATURES;
} // getRecognizedFeatures():String[]
/**
* Sets the state of a feature. This method is called by the component
* manager any time after reset when a feature changes state.
* <p>
* <strong>Note:</strong> Components should silently ignore features
* that do not affect the operation of the component.
*
* @param featureId The feature identifier.
* @param state The state of the feature.
*
* @throws SAXNotRecognizedException The component should not throw
* this exception.
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
throws XMLConfigurationException {
}
} // setFeature(String,boolean)
/**
* Returns a list of property identifiers that are recognized by
* this component. This method may return null if no properties
* are recognized by this component.
*/
return RECOGNIZED_PROPERTIES;
} // getRecognizedProperties():String[]
/**
* Sets the value of a property. This method is called by the component
* manager any time after reset when a property changes value.
* <p>
* <strong>Note:</strong> Components should silently ignore properties
* that do not affect the operation of the component.
*
* @param propertyId The property identifier.
* @param value The value of the property.
*
* @throws SAXNotRecognizedException The component should not throw
* this exception.
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
throws XMLConfigurationException {
}
}
}
} // setProperty(String,Object)
/**
* Returns the default state for a feature, or null if this
* component does not want to report a default value for this
* feature.
*
* @param featureId The feature identifier.
*
* @since Xerces 2.2.0
*/
return FEATURE_DEFAULTS[i];
}
}
return null;
} // getFeatureDefault(String):Boolean
/**
* Returns the default state for a property, or null if this
* component does not want to report a default value for this
* property.
*
* @param propertyId The property identifier.
*
* @since Xerces 2.2.0
*/
return PROPERTY_DEFAULTS[i];
}
}
return null;
} // getPropertyDefault(String):Object
if (fErrorReporter != null) {
new XIncludeMessageFormatter());
}
}
///////// END OF IMPLEMENTATION OF XMLComponents methods. //////////
//////// START OF IMPLEMENTATION OF XMLDOCUMENTSOURCE INTERFACE /////////
}
return fDocumentHandler;
}
/////// END OF IMPLENTATION OF XMLDOCUMENTSOURCE INTERFACE ///////////
/////////////// Implementation of XPointerSchema Methods //////////////////////
boolean fSubResourceIdentified;
/**
* set the Schema Name eg element , xpointer
*/
}
/**
* Return Schema Name eg element , xpointer
*
*/
return fSchemaName;
}
/**
* Parent Contenhandler for the this contenthandler.
* // not sure about the parameter type. It can be Contenthandler instead of Object type.
*/
}
/**
* return the Parent Contenthandler
*/
return fParentXIncludeHandler;
}
/**
* Content of the XPointer Schema. Xpath to be resolved.
*/
}
/**
* Return the XPointer Schema.
*/
return fSchemaPointer;
}
public boolean isSubResourceIndentified(){
return fSubResourceIdentified;
}
///////////End Implementation of XPointerSchema Methods //////////////////////
//////////// Tokens Playground ///////////////////
public void getTokens(){
if(fPointerToken == null){
fPointerToken = new Stack();
}
while(st.hasMoreTokens()){
try {
}catch(NumberFormatException e){
}
}
while(!tempPointerToken.empty()){
}
}//getTokens
public boolean hasMoreToken(){
if(fPointerToken.isEmpty())
return false;
else
return true;
}
public boolean getNextToken(){
if (!fPointerToken.isEmpty()){
if(currentToken instanceof Integer){
fCurrentTokenType = 1;
}
else{
fCurrentTokenType = 2;
}
return true;
}
else {
return false;
}
}
if( o instanceof Boolean )
return ((Boolean)o).booleanValue();
}
for (int i = 0; i < attrCount; i++) {
if(attrType != null && attrValue!= null && isIdAttribute(attributes,aaugs,i) && attrValue.equals(fCurrentTokenString)){
if(hasMoreToken()){
fCurrentTokenType = 0;
return true;
}
else{
includeElement = true;
fCurrentTokenType = 0;
fSubResourceIdentified = true;
return true;
}
}
}
return false;
}
if(!skip){
if(fCurrentTokenint == fElementCount){
if(hasMoreToken()){
fCurrentTokenType = 0;
return true;
}
else{
includeElement = true;
fCurrentTokenType = 0;
fSubResourceIdentified =true;
return true;
}
}else{
skip = true;
return false;
}
}
return false;
}
}
/////////// END TOKEN PLAYGROUND ///////////////
///// START OF IMPLEMTATION OF XMLDocumentHandler methods //////////
throws XNIException {
getTokens();
}
}
}
throws XNIException {
}
}
}
}
int fCurrentToken ;
boolean includeElement;
boolean requiredToken=false;
if(fCurrentTokenType == 0)
getNextToken();
if(fCurrentTokenType ==1)
else if (fCurrentTokenType ==2)
if(requiredToken && hasMoreToken())
getNextToken();
elemCount++;
}
}
throws XNIException {
}else if(!ftempCurrentElement.empty()){
skip = false;
}
}
}
}
}
throws XNIException {
}
}
throws XNIException {
}
}
throws XNIException {
if (fDocumentHandler != null) {
}
}
throws XNIException {
}
}
throws XNIException {
}
}
}
}
}
}
}
}
return fDocumentSource;
}
}
if (fErrorReporter != null) {
key,
args,
}
// we won't worry about when error reporter is null, since there should always be
// at least the default error reporter
}
// used to know whether to pass declarations to the document handler
protected boolean isRootDocument() {
return this.fParentXIncludeHandler == null;
}
} // class XPointerElementhandler