Fields Summary |
---|
protected int | fElementAttributeLimit |
protected ExternalSubsetResolver | fExternalSubsetResolverExternal subset resolver. |
protected static final int | SCANNER_STATE_START_OF_MARKUPScanner state: start of markup. |
protected static final int | SCANNER_STATE_CONTENTScanner state: content. |
protected static final int | SCANNER_STATE_PIScanner state: processing instruction. |
protected static final int | SCANNER_STATE_DOCTYPEScanner state: DOCTYPE. |
protected static final int | SCANNER_STATE_XML_DECLScanner state: XML Declaration |
protected static final int | SCANNER_STATE_ROOT_ELEMENTScanner state: root element. |
protected static final int | SCANNER_STATE_COMMENTScanner state: comment. |
protected static final int | SCANNER_STATE_REFERENCEScanner state: reference. |
protected static final int | SCANNER_STATE_ATTRIBUTE |
protected static final int | SCANNER_STATE_ATTRIBUTE_VALUE |
protected static final int | SCANNER_STATE_END_OF_INPUTScanner state: end of input. |
protected static final int | SCANNER_STATE_TERMINATEDScanner state: terminated. |
protected static final int | SCANNER_STATE_CDATAScanner state: CDATA section. |
protected static final int | SCANNER_STATE_TEXT_DECLScanner state: Text declaration. |
protected static final int | SCANNER_STATE_CHARACTER_DATAScanner state: Text declaration. |
protected static final int | SCANNER_STATE_START_ELEMENT_TAG |
protected static final int | SCANNER_STATE_END_ELEMENT_TAG |
protected static final int | SCANNER_STATE_CHAR_REFERENCE |
protected static final int | SCANNER_STATE_BUILT_IN_REFS |
protected static final String | NOTIFY_BUILTIN_REFSFeature identifier: notify built-in refereces. |
protected static final String | ENTITY_RESOLVERProperty identifier: entity resolver. |
private static final String[] | RECOGNIZED_FEATURESRecognized features. |
private static final Boolean[] | FEATURE_DEFAULTSFeature defaults. |
private static final String[] | RECOGNIZED_PROPERTIESRecognized properties. |
private static final Object[] | PROPERTY_DEFAULTSProperty defaults. |
protected static final char[] | cdata |
protected static final char[] | xmlDecl |
protected static final char[] | endTag |
private static final boolean | DEBUG_SCANNER_STATEDebug scanner state. |
private static final boolean | DEBUG_DISPATCHERDebug driver. |
protected static final boolean | DEBUG_START_END_ELEMENTDebug content driver scanning. |
protected static final boolean | DEBUG_NEXTDebug driver next |
protected static final boolean | DEBUGDebug driver next |
protected static final boolean | DEBUG_COALESCE |
protected XMLDocumentHandler | fDocumentHandlerDocument handler. |
protected int | fScannerLastState |
protected XMLEntityStorage | fEntityStoreEntity Storage |
protected int[] | fEntityStackEntity stack. |
protected int | fMarkupDepthMarkup depth. |
protected boolean | fEmptyElement |
protected boolean | fReadingAttributes |
protected int | fScannerStateScanner state. |
protected boolean | fInScanContentSubScanner state: inside scanContent method. |
protected boolean | fLastSectionWasCData |
protected boolean | fLastSectionWasEntityReference |
protected boolean | fLastSectionWasCharacterData |
protected boolean | fHasExternalDTDhas external dtd |
protected boolean | fStandaloneStandalone. |
protected String | fVersion |
protected QName | fCurrentElementCurrent element. |
protected ElementStack | fElementStackElement stack. |
protected ElementStack2 | fElementStack2 |
protected String | fPITargetDocument system identifier.
REVISIT: So what's this used for? - NG
protected String fDocumentSystemId; |
protected XMLString | fPIData |
protected boolean | fNotifyBuiltInRefsNotify built-in references. |
protected boolean | fReplaceEntityReferences |
protected boolean | fSupportExternalEntities |
protected boolean | fReportCdataEvent |
protected boolean | fIsCoalesce |
protected String | fDeclaredEncoding |
protected boolean | fDisallowDoctypeDisallow doctype declaration. |
protected Driver | fDriverActive driver. |
protected Driver | fContentDriverContent driver. |
protected QName | fElementQNameElement QName. |
protected QName | fAttributeQNameAttribute QName. |
protected XMLAttributesIteratorImpl | fAttributesCHANGED: Using XMLAttributesIteratorImpl instead of XMLAttributesImpl. This class
implements Iterator interface so we can directly give Attributes in the form of
iterator. |
protected XMLString | fTempStringString. |
protected XMLString | fTempString2String. |
private String[] | fStringsArray of 3 strings. |
protected XMLStringBuffer | fStringBufferMaking the buffer accesible to derived class -- String buffer. |
protected XMLStringBuffer | fStringBuffer2Making the buffer accesible to derived class -- String buffer. |
protected XMLStringBuffer | fContentBufferMaking the buffer accesible to derived class -- stores PI data |
private final char[] | fSingleCharSingle character array. |
private String | fCurrentEntityName |
protected boolean | fScanToEnd |
protected DTDGrammarUtil | dtdGrammarUtil |
protected boolean | fAddDefaultAttr |
protected boolean | foundBuiltInRefs |
protected SecurityManager | fSecurityManager |
static final short | MAX_DEPTH_LIMIT |
static final short | ELEMENT_ARRAY_LENGTH |
static final short | MAX_POINTER_AT_A_DEPTH |
static final boolean | DEBUG_SKIP_ALGORITHM |
String[] | fElementArray |
short | fLastPointerLocation |
short | fElementPointer |
short[] | fPointerInfo |
protected String | fElementRawname |
protected boolean | fShouldSkip |
protected boolean | fAdd |
protected boolean | fSkip |
private Augmentations | fTempAugmentationsReusable Augmentations. |
protected boolean | fUsebuffer |
Methods Summary |
---|
void | addElement(java.lang.String rawname)
if(fElementPointer < ELEMENT_ARRAY_LENGTH){
//storing element raw name in a linear list of array
fElementArray[fElementPointer] = rawname ;
//storing elemnetPointer for particular element depth
if(DEBUG_SKIP_ALGORITHM){
StringBuffer sb = new StringBuffer() ;
sb.append(" Storing element information ") ;
sb.append(" fElementPointer = " + fElementPointer) ;
sb.append(" fElementRawname = " + fElementQName.rawname) ;
sb.append(" fElementStack.fDepth = " + fElementStack.fDepth);
System.out.println(sb.toString()) ;
}
//store pointer information only when element depth is less MAX_DEPTH_LIMIT
if(fElementStack.fDepth < MAX_DEPTH_LIMIT){
short column = storePointerForADepth(fElementPointer);
if(column > 0){
short pointer = getElementPointer((short)fElementStack.fDepth, (short)(column - 1) );
//identity comparison shouldn't take much time and we can rely on this
//since its guaranteed to have same object id for same string.
if(rawname == fElementArray[pointer]){
fShouldSkip = true ;
fLastPointerLocation = pointer ;
//reset the things and return.
resetPointer((short)fElementStack.fDepth , column) ;
fElementArray[fElementPointer] = null ;
return ;
}else{
fShouldSkip = false ;
}
}
}
fElementPointer++ ;
}
|
boolean | canStore(short depth, short column)
//colum = 0 , means first element at particular depth
//column = 1, means second element at particular depth
// calle should make sure that it doesn't call for value outside allowed co-ordinates
return fPointerInfo[depth][column] == 0 ? true : false ;
|
protected com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Driver | createContentDriver()Creates a content Driver.
return new FragmentContentDriver();
|
public void | endEntity(java.lang.String name, com.sun.org.apache.xerces.internal.xni.Augmentations augs)This method notifies the end of an entity. The DTD has the pseudo-name
of "[dtd]" parameter entity names start with '%'; and general entities
are just specified by their name.
/**
* // flush possible pending output buffer - see scanContent
* if (fInScanContent && fStringBuffer.length != 0
* && fDocumentHandler != null) {
* fDocumentHandler.characters(fStringBuffer, null);
* fStringBuffer.length = 0; // make sure we know it's been flushed
* }
*/
super.endEntity(name, augs);
// make sure markup is properly balanced
if (fMarkupDepth != fEntityStack[fEntityDepth]) {
reportFatalError("MarkupEntityMismatch", null);
}
/**/
// call handler
if (fDocumentHandler != null && !fScanningAttribute) {
if (!name.equals("[xml]")) {
fDocumentHandler.endGeneralEntity(name, null);
}
}
|
public com.sun.org.apache.xerces.internal.util.XMLAttributesIteratorImpl | getAttributeIterator()return the attribute iterator implementation
if(dtdGrammarUtil != null && fAddDefaultAttr){
dtdGrammarUtil.addDTDDefaultAttrs(fElementQName,fAttributes);
fAddDefaultAttr = false;
}
return fAttributes;
|
public com.sun.org.apache.xerces.internal.xni.XMLString | getCharacterData()
if(fUsebuffer){
return fContentBuffer ;
}else{
return fTempString;
}
|
public java.lang.String | getComment()
return fContentBuffer.toString();
|
public com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler | getDocumentHandler()Returns the document handler
return fDocumentHandler;
|
public java.lang.String | getDriverName(com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Driver driver)Returns the driver name.
if (DEBUG_DISPATCHER) {
if (driver != null) {
String name = driver.getClass().getName();
int index = name.lastIndexOf('.");
if (index != -1) {
name = name.substring(index + 1);
index = name.lastIndexOf('$");
if (index != -1) {
name = name.substring(index + 1);
}
}
return name;
}
}
return "null";
|
short | getElementPointer(short depth, short column)
//colum = 0 , means first element at particular depth
//column = 1, means second element at particular depth
// calle should make sure that it doesn't call for value outside allowed co-ordinates
return fPointerInfo[depth][column] ;
|
public com.sun.org.apache.xerces.internal.xni.QName | getElementQName()
if(fScannerLastState == XMLEvent.END_ELEMENT){
fElementQName.setValues(fElementStack.getLastPoppedElement());
}
return fElementQName ;
|
public java.lang.String | getEntityName()
//return the cached name
return fCurrentEntityName;
|
public java.lang.Boolean | getFeatureDefault(java.lang.String featureId)Returns the default state for a feature, or null if this
component does not want to report a default value for this
feature.
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId)) {
return FEATURE_DEFAULTS[i];
}
}
return null;
|
public com.sun.org.apache.xerces.internal.util.XMLStringBuffer | getPIData()
return fContentBuffer ;
|
public java.lang.String | getPITarget()
return fPITarget ;
|
public java.lang.Object | getPropertyDefault(java.lang.String propertyId)Returns the default state for a property, or null if this
component does not want to report a default value for this
property.
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
return PROPERTY_DEFAULTS[i];
}
}
return null;
|
public java.lang.String[] | getRecognizedFeatures()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 (String[])(RECOGNIZED_FEATURES.clone());
|
public java.lang.String[] | getRecognizedProperties()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 (String[])(RECOGNIZED_PROPERTIES.clone());
|
protected java.lang.String | getScannerStateName(int state)Returns the scanner state name.
switch (state) {
case SCANNER_STATE_DOCTYPE: return "SCANNER_STATE_DOCTYPE";
case SCANNER_STATE_ROOT_ELEMENT: return "SCANNER_STATE_ROOT_ELEMENT";
case SCANNER_STATE_START_OF_MARKUP: return "SCANNER_STATE_START_OF_MARKUP";
case SCANNER_STATE_COMMENT: return "SCANNER_STATE_COMMENT";
case SCANNER_STATE_PI: return "SCANNER_STATE_PI";
case SCANNER_STATE_CONTENT: return "SCANNER_STATE_CONTENT";
case SCANNER_STATE_REFERENCE: return "SCANNER_STATE_REFERENCE";
case SCANNER_STATE_END_OF_INPUT: return "SCANNER_STATE_END_OF_INPUT";
case SCANNER_STATE_TERMINATED: return "SCANNER_STATE_TERMINATED";
case SCANNER_STATE_CDATA: return "SCANNER_STATE_CDATA";
case SCANNER_STATE_TEXT_DECL: return "SCANNER_STATE_TEXT_DECL";
case SCANNER_STATE_ATTRIBUTE: return "SCANNER_STATE_ATTRIBUTE";
case SCANNER_STATE_ATTRIBUTE_VALUE: return "SCANNER_STATE_ATTRIBUTE_VALUE";
case SCANNER_STATE_START_ELEMENT_TAG: return "SCANNER_STATE_START_ELEMENT_TAG";
case SCANNER_STATE_END_ELEMENT_TAG: return "SCANNER_STATE_END_ELEMENT_TAG";
case SCANNER_STATE_CHARACTER_DATA: return "SCANNER_STATE_CHARACTER_DATA" ;
}
return "??? ("+state+')";
|
protected com.sun.org.apache.xerces.internal.xni.XMLString | getString()this function gets an XMLString (which is used to store the attribute value) from the special pool
maintained for attributes.
fAttributeCacheUsedCount tracks the number of attributes that has been consumed from the pool.
if all the attributes has been consumed, it adds a new XMLString inthe pool and returns the same
XMLString.
if(fAttributeCacheUsedCount < initialCacheCount || fAttributeCacheUsedCount < attributeValueCache.size()){
return (XMLString)attributeValueCache.get(fAttributeCacheUsedCount++);
} else{
XMLString str = new XMLString();
fAttributeCacheUsedCount++;
attributeValueCache.add(str);
return str;
}
|
private void | handleCharacter(char c, java.lang.String entity, com.sun.org.apache.xerces.internal.util.XMLStringBuffer content)Calls document handler with a single character resulting from
built-in entity resolution.
foundBuiltInRefs = true;
content.append(c);
if (fDocumentHandler != null) {
fSingleChar[0] = c;
if (fNotifyBuiltInRefs) {
fDocumentHandler.startGeneralEntity(entity, null, null, null);
}
fTempString.setValues(fSingleChar, 0, 1);
//fDocumentHandler.characters(fTempString, null);
if (fNotifyBuiltInRefs) {
fDocumentHandler.endGeneralEntity(entity, null);
}
}
|
public boolean | hasAttributes()
return fAttributes.getLength() > 0 ? true : false ;
|
public boolean | isStandAlone()return if the doucment is standalone
return fStandalone ;
|
public int | next()return the next state on the input
return fDriver.next();
|
static void | pr(java.lang.String str)
System.out.println(str) ;
|
public void | refresh()Implements XMLBufferListener interface.
refresh(0);
|
public void | refresh(int refreshPosition)receives callbacks from {@link XMLEntityReader } when buffer
is being changed.
//If you are reading attributes and you got a callback
//cache available attributes.
if(fReadingAttributes){
fAttributes.refresh();
}
if(fScannerState == SCANNER_STATE_CHARACTER_DATA){
//since fTempString directly matches to the underlying main buffer
//store the data into buffer
fContentBuffer.append(fTempString);
//clear the XMLString so that data can't be added again.
fTempString.length = 0;
fUsebuffer = true;
}
|
public void | reset(com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager componentManager)Resets the component. The component can query the component manager
about any features and properties that affect the operation of the
component.
super.reset(componentManager);
// other settings
// fDocumentSystemId = null;
// sax features
//fAttributes.setNamespaces(fNamespaces);
// xerces features
try{
fReportCdataEvent = componentManager.getFeature(Constants.STAX_REPORT_CDATA_EVENT);
} catch (XMLConfigurationException e) {
e.printStackTrace();
//note that default value of this feature is true in stax configuration
fReportCdataEvent = true;
}
try {
fSecurityManager = (SecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER);
} catch (XMLConfigurationException e) {
fSecurityManager = null;
}
fElementAttributeLimit = (fSecurityManager != null)?fSecurityManager.getElementAttrLimit():0;
try {
fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS);
} catch (XMLConfigurationException e) {
fNotifyBuiltInRefs = false;
}
try {
Object resolver = componentManager.getProperty(ENTITY_RESOLVER);
fExternalSubsetResolver = (resolver instanceof ExternalSubsetResolver) ?
(ExternalSubsetResolver) resolver : null;
} catch (XMLConfigurationException e) {
fExternalSubsetResolver = null;
}
// initialize vars
fMarkupDepth = 0;
fCurrentElement = null;
fElementStack.clear();
fHasExternalDTD = false;
fStandalone = false;
fInScanContent = false;
//skipping algorithm
fShouldSkip = false;
fAdd = false;
fSkip = false;
//attribute
fReadingAttributes = false;
//xxx: external entities are supported in Xerces
// it would be good to define feature for this case
fSupportExternalEntities = true;
fReplaceEntityReferences = true;
fIsCoalesce = false;
// setup Driver
setScannerState(SCANNER_STATE_CONTENT);
setDriver(fContentDriver);
fEntityStore = fEntityManager.getEntityStore();
dtdGrammarUtil = null;
//fEntityManager.test();
|
public void | reset(com.sun.org.apache.xerces.internal.impl.PropertyManager propertyManager)
super.reset(propertyManager);
// other settings
// fDocumentSystemId = null;
fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue();
fNotifyBuiltInRefs = false ;
// initialize vars
fMarkupDepth = 0;
fCurrentElement = null;
fShouldSkip = false;
fAdd = false;
fSkip = false;
fElementStack.clear();
//fElementStack2.clear();
fHasExternalDTD = false;
fStandalone = false;
//fReplaceEntityReferences = true;
//fSupportExternalEntities = true;
Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactoryImpl.IS_REPLACING_ENTITY_REFERENCES);
fReplaceEntityReferences = bo.booleanValue();
bo = (Boolean)propertyManager.getProperty(XMLInputFactoryImpl.IS_SUPPORTING_EXTERNAL_ENTITIES);
fSupportExternalEntities = bo.booleanValue();
Boolean cdata = (Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT) ;
if(cdata != null)
fReportCdataEvent = cdata.booleanValue() ;
Boolean coalesce = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_COALESCING) ;
if(coalesce != null)
fIsCoalesce = coalesce.booleanValue();
fReportCdataEvent = fIsCoalesce ? false : (fReportCdataEvent && true) ;
//if fIsCoalesce is set to true, set the value of fReplaceEntityReferences to true,
//if fIsCoalesce is set to false, take the value of fReplaceEntityReferences as set by application
fReplaceEntityReferences = fIsCoalesce ? true : fReplaceEntityReferences;
// setup Driver
//we dont need to do this -- nb.
//setScannerState(SCANNER_STATE_CONTENT);
//setDriver(fContentDriver);
fEntityStore = fEntityManager.getEntityStore();
//fEntityManager.test();
dtdGrammarUtil = null;
|
void | resetPointer(short depth, short column)
fPointerInfo[depth] [column] = (short)0;
|
protected void | scanAttribute(com.sun.org.apache.xerces.internal.xni.XMLAttributes attributes)Scans an attribute name value pair.
[41] Attribute ::= Name Eq AttValue
Note: This method assumes that the next
character on the stream is the first character of the attribute
name.
Note: This method uses the fAttributeQName and
fQName variables. The contents of these variables will be
destroyed.
if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanAttribute()");
// name
if (fNamespaces) {
fEntityScanner.scanQName(fAttributeQName);
} else {
String name = fEntityScanner.scanName();
fAttributeQName.setValues(null, name, name, null);
}
// equals
fEntityScanner.skipSpaces();
if (!fEntityScanner.skipChar('=")) {
reportFatalError("EqRequiredInAttribute",
new Object[] {fCurrentElement.rawname, fAttributeQName.rawname});
}
fEntityScanner.skipSpaces();
int attIndex = 0 ;
//REVISIT: one more case needs to be included: external PE and standalone is no
boolean isVC = fHasExternalDTD && !fStandalone;
//fTempString would store attribute value
///fTempString2 would store attribute non-normalized value
//this function doesn't use 'attIndex'. We are adding the attribute later
//after we have figured out that current attribute is not namespace declaration
//since scanAttributeValue doesn't use attIndex parameter therefore we
//can safely add the attribute later..
XMLString tmpStr = getString();
scanAttributeValue(tmpStr, fTempString2,
fAttributeQName.rawname, attributes,
attIndex, isVC);
// content
int oldLen = attributes.getLength();
//if the attribute name already exists.. new value is replaced with old value
attIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);
// WFC: Unique Att Spec
//attributes count will be same if the current attribute name already exists for this element name.
//this means there are two duplicate attributes.
if (oldLen == attributes.getLength()) {
reportFatalError("AttributeNotUnique",
new Object[]{fCurrentElement.rawname,
fAttributeQName.rawname});
}
//tmpString contains attribute value
//we are passing null as the attribute value
attributes.setValue(attIndex, null, tmpStr);
///xxx: nonNormalizedValue is not being set as it is not required by SAX & DOM
//attributes.setNonNormalizedValue(oldLen, fTempString2.toString());
attributes.setSpecified(attIndex, true);
if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +"<<< scanAttribute()");
|
protected boolean | scanCDATASection(com.sun.org.apache.xerces.internal.util.XMLStringBuffer contentBuffer, boolean complete)Scans a CDATA section.
Note: This method uses the fTempString and
fStringBuffer variables.
// call handler
if (fDocumentHandler != null) {
//fDocumentHandler.startCDATA(null);
}
while (true) {
//scanData will fill the contentBuffer
if (!fEntityScanner.scanData("]]>", contentBuffer)) {
break ;
/** We dont need all this code if we pass ']]>' as delimeter..
* int brackets = 2;
* while (fEntityScanner.skipChar(']')) {
* brackets++;
* }
*
* //When we find more than 2 square brackets
* if (fDocumentHandler != null && brackets > 2) {
* //we dont need to clear the buffer..
* //contentBuffer.clear();
* for (int i = 2; i < brackets; i++) {
* contentBuffer.append(']');
* }
* fDocumentHandler.characters(contentBuffer, null);
* }
*
* if (fEntityScanner.skipChar('>')) {
* break;
* }
* if (fDocumentHandler != null) {
* //we dont need to clear the buffer now..
* //contentBuffer.clear();
* contentBuffer.append("]]");
* fDocumentHandler.characters(contentBuffer, null);
* }
**/
} else {
int c = fEntityScanner.peekChar();
if (c != -1 && isInvalidLiteral(c)) {
if (XMLChar.isHighSurrogate(c)) {
//contentBuffer.clear();
//scan surrogates if any....
scanSurrogates(contentBuffer);
} else {
reportFatalError("InvalidCharInCDSect",
new Object[]{Integer.toString(c,16)});
fEntityScanner.scanChar();
}
}
//by this time we have also read surrogate contents if any...
if (fDocumentHandler != null) {
//fDocumentHandler.characters(contentBuffer, null);
}
}
}
fMarkupDepth--;
if (fDocumentHandler != null && contentBuffer.length > 0) {
//fDocumentHandler.characters(contentBuffer, null);
}
// call handler
if (fDocumentHandler != null) {
//fDocumentHandler.endCDATA(null);
}
return true;
|
protected void | scanCharReference()Scans a character reference.
[66] CharRef ::= '' [0-9]+ ';' | '' [0-9a-fA-F]+ ';'
fStringBuffer2.clear();
int ch = scanCharReferenceValue(fStringBuffer2, null);
fMarkupDepth--;
if (ch != -1) {
// call handler
if (fDocumentHandler != null) {
if (fNotifyCharRefs) {
fDocumentHandler.startGeneralEntity(fCharRefLiteral, null, null, null);
}
Augmentations augs = null;
if (fValidation && ch <= 0x20) {
if (fTempAugmentations != null) {
fTempAugmentations.removeAllItems();
}
else {
fTempAugmentations = new AugmentationsImpl();
}
augs = fTempAugmentations;
augs.putItem(Constants.CHAR_REF_PROBABLE_WS, Boolean.TRUE);
}
//xxx: How do we deal with this - how to return charReferenceValues
//now this is being commented because this is taken care in scanDocument()
//fDocumentHandler.characters(fStringBuffer2, null);
if (fNotifyCharRefs) {
fDocumentHandler.endGeneralEntity(fCharRefLiteral, null);
}
}
}
|
protected void | scanComment()Scans a comment.
[15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
Note: Called after scanning past '<!--'
fContentBuffer.clear();
scanComment(fContentBuffer);
//getTextCharacters can also be called for reading comments
fUsebuffer = true;
fMarkupDepth--;
|
protected int | scanContent(com.sun.org.apache.xerces.internal.util.XMLStringBuffer content)Scans element content.
//set the fTempString length to 0 before passing it on to scanContent
//scanContent sets the correct co-ordinates as per the content read
fTempString.length = 0;
int c = fEntityScanner.scanContent(fTempString);
content.append(fTempString);
fTempString.length = 0;
if (c == '\r") {
// happens when there is the character reference
//xxx: We know the next chracter.. we should just skip it and add ']' directlry
fEntityScanner.scanChar();
content.append((char)c);
c = -1;
} else if (c == ']") {
//fStringBuffer.clear();
//xxx: We know the next chracter.. we should just skip it and add ']' directlry
content.append((char)fEntityScanner.scanChar());
// remember where we are in case we get an endEntity before we
// could flush the buffer out - this happens when we're parsing an
// entity which ends with a ]
fInScanContent = true;
//
// We work on a single character basis to handle cases such as:
// ']]]>' which we might otherwise miss.
//
if (fEntityScanner.skipChar(']")) {
content.append(']");
while (fEntityScanner.skipChar(']")) {
content.append(']");
}
if (fEntityScanner.skipChar('>")) {
reportFatalError("CDEndInContent", null);
}
}
fInScanContent = false;
c = -1;
}
if (fDocumentHandler != null && content.length > 0) {
//fDocumentHandler.characters(content, null);
}
return c;
|
public boolean | scanDocument(boolean complete)Scans a document.
// keep dispatching "events"
fEntityManager.setEntityHandler(this);
//System.out.println(" get Document Handler in NSDocumentHandler " + fDocumentHandler );
int event = next();
do {
switch (event) {
case XMLStreamConstants.START_DOCUMENT :
//fDocumentHandler.startDocument(fEntityManager.getEntityScanner(),fEntityManager.getEntityScanner().getVersion(),fNamespaceContext,null);// not able to get
break;
case XMLStreamConstants.START_ELEMENT :
//System.out.println(" in scann element");
//fDocumentHandler.startElement(getElementQName(),fAttributes,null);
break;
case XMLStreamConstants.CHARACTERS :
fDocumentHandler.characters(getCharacterData(),null);
break;
case XMLStreamConstants.SPACE:
//check if getCharacterData() is the right function to retrieve ignorableWhitespace information.
//System.out.println("in the space");
//fDocumentHandler.ignorableWhitespace(getCharacterData(), null);
break;
case XMLStreamConstants.ENTITY_REFERENCE :
//entity reference callback are given in startEntity
break;
case XMLStreamConstants.PROCESSING_INSTRUCTION :
fDocumentHandler.processingInstruction(getPITarget(),getPIData(),null);
break;
case XMLStreamConstants.COMMENT :
//System.out.println(" in COMMENT of the XMLNSDocumentScannerImpl");
fDocumentHandler.comment(getCharacterData(),null);
break;
case XMLStreamConstants.DTD :
//all DTD related callbacks are handled in DTDScanner.
//1. Stax doesn't define DTD states as it does for XML Document.
//therefore we don't need to take care of anything here. So Just break;
break;
case XMLStreamConstants.CDATA:
fDocumentHandler.startCDATA(null);
//xxx: check if CDATA values comes from getCharacterData() function
fDocumentHandler.characters(getCharacterData(),null);
fDocumentHandler.endCDATA(null);
//System.out.println(" in CDATA of the XMLNSDocumentScannerImpl");
break;
case XMLStreamConstants.NOTATION_DECLARATION :
break;
case XMLStreamConstants.ENTITY_DECLARATION :
break;
case XMLStreamConstants.NAMESPACE :
break;
case XMLStreamConstants.ATTRIBUTE :
break;
case XMLStreamConstants.END_ELEMENT :
//do not give callback here.
//this callback is given in scanEndElement function.
//fDocumentHandler.endElement(getElementQName(),null);
break;
default :
throw new InternalError("processing event: " + event);
}
//System.out.println("here in before calling next");
event = next();
//System.out.println("here in after calling next");
} while (event!=XMLStreamConstants.END_DOCUMENT && complete);
if(event == XMLStreamConstants.END_DOCUMENT) {
fDocumentHandler.endDocument(null);
return false;
}
return true;
|
protected int | scanEndElement()Scans an end element.
[42] ETag ::= '</' Name S? '>'
Note: This method uses the fElementQName variable.
The contents of this variable will be destroyed. The caller should
copy the needed information out of this variable before calling
this method.
if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +">>> scanEndElement()");
// pop context
QName endElementName = fElementStack.popElement();
String rawname = endElementName.rawname;
if(DEBUG)System.out.println("endElementName = " + endElementName.toString());
// Take advantage of the fact that next string _should_ be "fElementQName.rawName",
//In scanners most of the time is consumed on checks done for XML characters, we can
// optimize on it and avoid the checks done for endElement,
//we will also avoid symbol table lookup - neeraj.bajaj@sun.com
// this should work both for namespace processing true or false...
//REVISIT: if the string is not the same as expected.. we need to do better error handling..
//We can skip this for now... In any case if the string doesn't match -- document is not well formed.
if (!fEntityScanner.skipString(endElementName.rawname)) {
reportFatalError("ETagRequired", new Object[]{rawname});
}
// end
fEntityScanner.skipSpaces();
if (!fEntityScanner.skipChar('>")) {
reportFatalError("ETagUnterminated",
new Object[]{rawname});
}
fMarkupDepth--;
//we have increased the depth for two markup "<" characters
fMarkupDepth--;
// check that this element was opened in the same entity
if (fMarkupDepth < fEntityStack[fEntityDepth - 1]) {
reportFatalError("ElementEntityMismatch",
new Object[]{rawname});
}
//We should not be popping out the context here in endELement becaause the namespace context is still
//valid when parser is at the endElement state.
//if (fNamespaces) {
// fNamespaceContext.popContext();
//}
// call handler
if (fDocumentHandler != null ) {
//end element is scanned in this function so we can send a callback
//here.
//<strong>we shouldn't be sending callback in scanDocument()</strong>
fDocumentHandler.endElement(endElementName, null);
}
if(dtdGrammarUtil != null)
dtdGrammarUtil.endElement(endElementName);
return fMarkupDepth;
|
protected void | scanEntityReference(com.sun.org.apache.xerces.internal.util.XMLStringBuffer content)Scans an entity reference.
String name = fEntityScanner.scanName();
if (name == null) {
reportFatalError("NameRequiredInReference", null);
}
if (!fEntityScanner.skipChar(';")) {
reportFatalError("SemicolonRequiredInReference", new Object []{name});
}
if (fEntityStore.isUnparsedEntity(name)) {
reportFatalError("ReferenceToUnparsedEntity", new Object[]{name});
}
fMarkupDepth--;
fCurrentEntityName = name;
// handle built-in entities
if (name == fAmpSymbol) {
handleCharacter('&", fAmpSymbol, content);
fScannerState = SCANNER_STATE_BUILT_IN_REFS;
return ;
} else if (name == fLtSymbol) {
handleCharacter('<", fLtSymbol, content);
fScannerState = SCANNER_STATE_BUILT_IN_REFS;
return ;
} else if (name == fGtSymbol) {
handleCharacter('>", fGtSymbol, content);
fScannerState = SCANNER_STATE_BUILT_IN_REFS;
return ;
} else if (name == fQuotSymbol) {
handleCharacter('"", fQuotSymbol, content);
fScannerState = SCANNER_STATE_BUILT_IN_REFS;
return ;
} else if (name == fAposSymbol) {
handleCharacter('\'", fAposSymbol, content);
fScannerState = SCANNER_STATE_BUILT_IN_REFS;
return ;
}
//1. if the entity is external and support to external entities is not required
// 2. or entities should not be replaced
//3. or if it is built in entity reference.
if((fEntityStore.isExternalEntity(name) && !fSupportExternalEntities) || (!fEntityStore.isExternalEntity(name) && !fReplaceEntityReferences) || foundBuiltInRefs){
fScannerState = SCANNER_STATE_REFERENCE;
return ;
}
// start general entity
if (!fEntityStore.isDeclaredEntity(name)) {
//SUPPORT_DTD=false && ReplaceEntityReferences should throw exception
if (fDisallowDoctype && fReplaceEntityReferences) {
reportFatalError("EntityNotDeclared", new Object[]{name});
return;
}
//REVISIT: one more case needs to be included: external PE and standalone is no
if ( fHasExternalDTD && !fStandalone) {
if (fValidation)
fErrorReporter.reportError(fEntityScanner, XMLMessageFormatter.XML_DOMAIN,"EntityNotDeclared",
new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR);
} else
reportFatalError("EntityNotDeclared", new Object[]{name});
}
//we are starting the entity even if the entity was not declared
//if that was the case it its taken care in XMLEntityManager.startEntity()
//we immediately call the endEntity. Application gets to know if there was
//any entity that was not declared.
fEntityManager.startEntity(name, false);
//set the scaner state to content.. parser will automatically revive itself at any point of time.
//setScannerState(SCANNER_STATE_CONTENT);
//return true ;
|
protected void | scanPIData(java.lang.String target, com.sun.org.apache.xerces.internal.util.XMLStringBuffer data)Scans a processing data. This is needed to handle the situation
where a document starts with a processing instruction whose
target name starts with "xml". (e.g. xmlfoo)
super.scanPIData(target, data);
//set the PI target and values
fPITarget = target ;
fMarkupDepth--;
|
protected boolean | scanStartElement()Scans a start element. This method will handle the binding of
namespace information and notifying the handler of the start
of the element.
[44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
[40] STag ::= '<' Name (S Attribute)* S? '>'
Note: This method assumes that the leading
'<' character has been consumed.
Note: This method uses the fElementQName and
fAttributes variables. The contents of these variables will be
destroyed. The caller should copy important information out of
these variables before calling this method.
NB: Content in fAttributes is valid only till the state of the parser is XMLEvent.START_ELEMENT
if (DEBUG_START_END_ELEMENT) System.out.println( this.getClass().toString() + ">>> scanStartElement()");
//when skipping is true and no more elements should be added
if(fSkip && !fAdd){
//get the stored element -- if everything goes right this should match the
//token in the buffer
QName name = fElementStack.getNext();
if(DEBUG_SKIP_ALGORITHM){
System.out.println("Trying to skip String = " + name.rawname);
}
//Be conservative -- if skipping fails -- stop.
fSkip = fEntityScanner.skipString(name.rawname);
if(fSkip){
if(DEBUG_SKIP_ALGORITHM){
System.out.println("Element SUCESSFULLY skipped = " + name.rawname);
}
fElementStack.push();
fElementQName = name;
}else{
//if skipping fails reposition the stack or fallback to normal way of processing
fElementStack.reposition();
if(DEBUG_SKIP_ALGORITHM){
System.out.println("Element was NOT skipped, REPOSITIONING stack" );
}
}
}
//we are still at the stage of adding elements
//the elements were not matched or
//fSkip is not set to true
if(!fSkip || fAdd){
//get the next element from the stack
fElementQName = fElementStack.nextElement();
// name
if (fNamespaces) {
fEntityScanner.scanQName(fElementQName);
} else {
String name = fEntityScanner.scanName();
fElementQName.setValues(null, name, name, null);
}
if(DEBUG)System.out.println("Element scanned in start element is " + fElementQName.toString());
if(DEBUG_SKIP_ALGORITHM){
if(fAdd){
System.out.println("Elements are being ADDED -- elemet added is = " + fElementQName.rawname + " at count = " + fElementStack.fCount);
}
}
}
//when the elements are being added , we need to check if we are set for skipping the elements
if(fAdd){
//this sets the value of fAdd variable
fElementStack.matchElement(fElementQName);
}
//xxx: We dont need another pointer, fCurrentElement, we can use fElementQName
fCurrentElement = fElementQName;
String rawname = fElementQName.rawname;
fEmptyElement = false;
fAttributes.removeAllAttributes();
if(!seekCloseOfStartTag()){
fReadingAttributes = true;
fAttributeCacheUsedCount =0;
fStringBufferIndex =0;
fAddDefaultAttr = true;
do {
scanAttribute(fAttributes);
if (fSecurityManager != null && fAttributes.getLength() > fElementAttributeLimit){
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
"ElementAttributeLimit",
new Object[]{rawname, new Integer(fAttributes.getLength()) },
XMLErrorReporter.SEVERITY_FATAL_ERROR );
}
} while (!seekCloseOfStartTag());
fReadingAttributes=false;
}
if (fEmptyElement) {
//decrease the markup depth..
fMarkupDepth--;
// check that this element was opened in the same entity
if (fMarkupDepth < fEntityStack[fEntityDepth - 1]) {
reportFatalError("ElementEntityMismatch",
new Object[]{fCurrentElement.rawname});
}
// call handler
if (fDocumentHandler != null) {
fDocumentHandler.emptyElement(fElementQName, fAttributes, null);
}
//We should not be popping out the context here in endELement becaause the namespace context is still
//valid when parser is at the endElement state.
//if (fNamespaces) {
// fNamespaceContext.popContext();
//}
//pop the element off the stack..
fElementStack.popElement();
} else {
if(dtdGrammarUtil != null)
dtdGrammarUtil.startElement(fElementQName, fAttributes);
if(fDocumentHandler != null){
//complete element and attributes are traversed in this function so we can send a callback
//here.
//<strong>we shouldn't be sending callback in scanDocument()</strong>
fDocumentHandler.startElement(fElementQName, fAttributes, null);
}
}
if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() + "<<< scanStartElement(): "+fEmptyElement);
return fEmptyElement;
|
protected void | scanXMLDeclOrTextDecl(boolean scanningTextDecl)Scans an XML or text declaration.
[23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
[24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
[80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" )
[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
[32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'")
| ('"' ('yes' | 'no') '"'))
[77] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'
// scan decl
super.scanXMLDeclOrTextDecl(scanningTextDecl, fStrings);
fMarkupDepth--;
// pseudo-attribute values
String version = fStrings[0];
String encoding = fStrings[1];
String standalone = fStrings[2];
fDeclaredEncoding = encoding;
// set standalone
fStandalone = standalone != null && standalone.equals("yes");
///xxx see where its used.. this is not used anywhere. it may be useful for entity to store this information
//but this information is only related with Document Entity.
fEntityManager.setStandalone(fStandalone);
// call handler
if (fDocumentHandler != null) {
if (scanningTextDecl) {
fDocumentHandler.textDecl(version, encoding, null);
} else {
fDocumentHandler.xmlDecl(version, encoding, standalone, null);
}
}
if(version != null){
fEntityScanner.setVersion(version);
fEntityScanner.setXMLVersion(version);
}
// set encoding on reader, only if encoding was not specified by the application explicitly
if (encoding != null && !fEntityScanner.getCurrentEntity().isEncodingExternallySpecified()) {
fEntityScanner.setEncoding(encoding);
}
|
protected boolean | seekCloseOfStartTag()Looks for the close of start tag, i.e. if it finds '>' or '/>'
Characters are consumed.
// spaces
boolean sawSpace = fEntityScanner.skipSpaces();
// end tag?
final int c = fEntityScanner.peekChar();
if (c == '>") {
fEntityScanner.scanChar();
return true;
} else if (c == '/") {
fEntityScanner.scanChar();
if (!fEntityScanner.skipChar('>")) {
reportFatalError("ElementUnterminated",
new Object[]{fElementQName.rawname});
}
fEmptyElement = true;
return true;
} else if (!isValidNameStartChar(c) || !sawSpace) {
reportFatalError("ElementUnterminated", new Object[]{fElementQName.rawname});
}
return false;
|
public void | setDocumentHandler(com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler documentHandler)setDocumentHandler
fDocumentHandler = documentHandler;
//System.out.println(" In Set DOCUMENT HANDLER" + fDocumentHandler + " scanner =" + this);
|
protected final void | setDriver(com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$Driver driver)Sets the Driver.
fDriver = driver;
if (DEBUG_DISPATCHER) {
System.out.print("%%% setDriver: ");
System.out.print(getDriverName(driver));
System.out.println();
}
|
public void | setFeature(java.lang.String featureId, boolean state)Sets the state of a feature. This method is called by the component
manager any time after reset when a feature changes state.
Note: Components should silently ignore features
that do not affect the operation of the component.
super.setFeature(featureId, state);
// Xerces properties
if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
String feature = featureId.substring(Constants.XERCES_FEATURE_PREFIX.length());
if (feature.equals(Constants.NOTIFY_BUILTIN_REFS_FEATURE)) {
fNotifyBuiltInRefs = state;
}
}
|
public void | setInputSource(com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource inputSource)Sets the input source.
fEntityManager.setEntityHandler(this);
fEntityManager.startEntity("$fragment$", inputSource, false, true);
// fDocumentSystemId = fEntityManager.expandSystemId(inputSource.getSystemId());
|
public void | setProperty(java.lang.String propertyId, java.lang.Object value)Sets the value of a property. This method is called by the component
manager any time after reset when a property changes value.
Note: Components should silently ignore properties
that do not affect the operation of the component.
super.setProperty(propertyId, value);
// Xerces properties
if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
if (suffixLength == Constants.ENTITY_MANAGER_PROPERTY.length() &&
propertyId.endsWith(Constants.ENTITY_MANAGER_PROPERTY)) {
fEntityManager = (XMLEntityManager)value;
return;
}
if (suffixLength == Constants.ENTITY_RESOLVER_PROPERTY.length() &&
propertyId.endsWith(Constants.ENTITY_RESOLVER_PROPERTY)) {
fExternalSubsetResolver = (value instanceof ExternalSubsetResolver) ?
(ExternalSubsetResolver) value : null;
return;
}
}
// Xerces properties
if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
String property = propertyId.substring(Constants.XERCES_PROPERTY_PREFIX.length());
if (property.equals(Constants.ENTITY_MANAGER_PROPERTY)) {
fEntityManager = (XMLEntityManager)value;
}
return;
}
|
protected final void | setScannerState(int state)Sets the scanner state.
fScannerState = state;
if (DEBUG_SCANNER_STATE) {
System.out.print("### setScannerState: ");
//System.out.print(fScannerState);
System.out.print(getScannerStateName(state));
System.out.println();
}
|
protected boolean | skipElement()
if(!fShouldSkip) return false ;
if(fLastPointerLocation != 0){
//Look at the next element stored in the array list.. we might just get a match.
String rawname = fElementArray[fLastPointerLocation + 1] ;
if(rawname != null && skipFromTheBuffer(rawname)){
fLastPointerLocation++ ;
if(DEBUG_SKIP_ALGORITHM){
System.out.println("Element " + fElementRawname + " was SKIPPED at pointer location = " + fLastPointerLocation);
}
return true ;
} else{
//reset it back to zero... we haven't got the correct subset yet.
fLastPointerLocation = 0 ;
}
}
//xxx: we can put some logic here as from what column it should start looking
//for now we always start at 0
//fallback to tolerant algorithm, it would look for differnt element stored at different
//depth and get us the pointer location.
return fShouldSkip && skipElement((short)0);
|
boolean | skipElement(short column)
short depth = (short)fElementStack.fDepth ;
if(depth > MAX_DEPTH_LIMIT){
return fShouldSkip = false ;
}
for(short i = column ; i < MAX_POINTER_AT_A_DEPTH ; i++){
short pointer = getElementPointer(depth , i ) ;
if(pointer == 0){
return fShouldSkip = false ;
}
if(fElementArray[pointer] != null && skipFromTheBuffer(fElementArray[pointer])){
if(DEBUG_SKIP_ALGORITHM){
System.out.println();
System.out.println("Element " + fElementRawname + " was SKIPPED at depth = " + fElementStack.fDepth + " column = " + column );
System.out.println();
}
fLastPointerLocation = pointer ;
return fShouldSkip = true ;
}
}
return fShouldSkip = false ;
|
boolean | skipFromTheBuffer(java.lang.String rawname)
if(fEntityScanner.skipString(rawname)){
char c = (char)fEntityScanner.peekChar() ;
//If the start element was completely skipped we should encounter either ' '(space),
//or '/' (in case of empty element) or '>'
if( c == ' " || c == '/" || c == '>"){
fElementRawname = rawname ;
return true ;
} else{
return false;
}
} else
return false ;
|
boolean | skipQElement(java.lang.String rawname)
final int c = fEntityScanner.getChar(rawname.length());
//if this character is still valid element name -- this means string can't match
if(XMLChar.isName(c)){
return false;
}else{
return fEntityScanner.skipString(rawname);
}
|
public void | startEntity(java.lang.String name, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier identifier, java.lang.String encoding, com.sun.org.apache.xerces.internal.xni.Augmentations augs)This method notifies of the start of an entity. The DTD has the
pseudo-name of "[dtd]" parameter entity names start with '%'; and
general entities are just specified by their name.
// keep track of this entity before fEntityDepth is increased
if (fEntityDepth == fEntityStack.length) {
int[] entityarray = new int[fEntityStack.length * 2];
System.arraycopy(fEntityStack, 0, entityarray, 0, fEntityStack.length);
fEntityStack = entityarray;
}
fEntityStack[fEntityDepth] = fMarkupDepth;
super.startEntity(name, identifier, encoding, augs);
// WFC: entity declared in external subset in standalone doc
if(fStandalone && fEntityStore.isEntityDeclInExternalSubset(name)) {
reportFatalError("MSG_REFERENCE_TO_EXTERNALLY_DECLARED_ENTITY_WHEN_STANDALONE",
new Object[]{name});
}
/** we are not calling the handlers yet.. */
// call handler
if (fDocumentHandler != null && !fScanningAttribute) {
if (!name.equals("[xml]")) {
fDocumentHandler.startGeneralEntity(name, identifier, encoding, null);
}
}
|
short | storePointerForADepth(short elementPointer)
short depth = (short) fElementStack.fDepth ;
//Stores element pointer locations at particular depth , only 4 pointer locations
//are stored at particular depth for now.
for(short i = 0 ; i < MAX_POINTER_AT_A_DEPTH ; i++){
if(canStore(depth, i)){
fPointerInfo[depth][i] = elementPointer ;
if(DEBUG_SKIP_ALGORITHM){
StringBuffer sb = new StringBuffer() ;
sb.append(" Pointer information ") ;
sb.append(" fElementPointer = " + fElementPointer) ;
sb.append(" fElementStack.fDepth = " + fElementStack.fDepth);
sb.append(" column = " + i ) ;
System.out.println(sb.toString()) ;
}
return i;
}
//else
//pointer was not stored because we reached the limit
}
return -1 ;
|