public FastInfosetStreamWriterOutput(StAXDocumentSerializer out, JAXBContextImpl context) { super(out, NoEscapeHandler.theInstance); this.fiout = out; this.localNames = context.getUTF8NameTable(); final VocabularyApplicationData vocabAppData = fiout.getVocabularyApplicationData(); AppData appData = null; if (vocabAppData == null || !(vocabAppData instanceof AppData)) { appData = new AppData(); fiout.setVocabularyApplicationData(appData); } else { appData = (AppData)vocabAppData; } final TablesPerJAXBContext tablesPerContext = appData.contexts.get(context); if (tablesPerContext != null) { tables = tablesPerContext; /** * Obtain the current local name index. Thus will be used to * calculate the maximum index value when serializing for this context */ tables.clearOrResetTables(out.getLocalNameIndex()); } else { tables = new TablesPerJAXBContext(context, out.getLocalNameIndex()); appData.contexts.put(context, tables); } }
@Override public void beginStartTag(int prefix, String localName) throws IOException { fiout.writeLowLevelTerminationAndMark(); int type = EncodingConstants.ELEMENT; if (nsContext.getCurrent().count() > 0) { final NamespaceContextImpl.Element nse = nsContext.getCurrent(); fiout.writeLowLevelStartNamespaces(); for (int i = nse.count() - 1; i >= 0; i--) { final String uri = nse.getNsUri(i); if (uri.length() == 0 && nse.getBase() == 1) continue; // no point in definint xmlns='' on the root fiout.writeLowLevelNamespace(nse.getPrefix(i), uri); } fiout.writeLowLevelEndNamespaces(); type= 0; } final boolean isIndexed = fiout.writeLowLevelStartElement( type, nsContext.getPrefix(prefix), localName, nsContext.getNamespaceURI(prefix)); if (!isIndexed) tables.incrementMaxIndexValue(); }
/** * Clear or reset the tables. * <p> * @param intialIndexOffset the initial index offset to calculate * the maximum possible index */ public void clearOrResetTables(int intialIndexOffset) { if (requiresClear) { requiresClear = false; // Increment offset to new position indexOffset += maxIndex; // Reset the maximum known value of an index maxIndex = intialIndexOffset + elementIndexes.length + attributeIndexes.length; // Check if there is enough free space // If overflow if ((indexOffset + maxIndex) < 0) { clearAll(); } } else { // Reset the maximum known value of an index maxIndex = intialIndexOffset + elementIndexes.length + attributeIndexes.length; // Check if there is enough free space // If overflow if ((indexOffset + maxIndex) < 0) { resetAll(); } } }
@Override public void beginStartTag(int prefix, String localName) throws IOException { fiout.writeLowLevelTerminationAndMark(); int type = EncodingConstants.ELEMENT; if (nsContext.getCurrent().count() > 0) { final NamespaceContextImpl.Element nse = nsContext.getCurrent(); fiout.writeLowLevelStartNamespaces(); for (int i = nse.count() - 1; i >= 0; i--) { final String uri = nse.getNsUri(i); if (uri.length() == 0 && nse.getBase() == 1) continue; // no point in definint xmlns='' on the root fiout.writeLowLevelNamespace(nse.getPrefix(i), uri); } fiout.writeLowLevelEndNamespaces(); type= 0; } final boolean isIndexed = fiout.writeLowLevelStartElement( type, nsContext.getPrefix(prefix), localName, nsContext.getNamespaceURI(prefix)); if (!isIndexed) tables.incrementMaxIndexValue(); }
public FastInfosetStreamWriterOutput(StAXDocumentSerializer out, JAXBContextImpl context) { super(out, NoEscapeHandler.theInstance); this.fiout = out; this.localNames = context.getUTF8NameTable(); final VocabularyApplicationData vocabAppData = fiout.getVocabularyApplicationData(); AppData appData = null; if (vocabAppData == null || !(vocabAppData instanceof AppData)) { appData = new AppData(); fiout.setVocabularyApplicationData(appData); } else { appData = (AppData)vocabAppData; } final TablesPerJAXBContext tablesPerContext = appData.contexts.get(context); if (tablesPerContext != null) { tables = tablesPerContext; /** * Obtain the current local name index. Thus will be used to * calculate the maximum index value when serializing for this context */ tables.clearOrResetTables(out.getLocalNameIndex()); } else { tables = new TablesPerJAXBContext(context, out.getLocalNameIndex()); appData.contexts.put(context, tables); } }
/** * Clear or reset the tables. * <p> * @param initialIndexOffset the initial index offset to calculate * the maximum possible index */ public void clearOrResetTables(int intialIndexOffset) { if (requiresClear) { requiresClear = false; // Increment offset to new position indexOffset += maxIndex; // Reset the maximum known value of an index maxIndex = intialIndexOffset + elementIndexes.length + attributeIndexes.length; // Check if there is enough free space // If overflow if ((indexOffset + maxIndex) < 0) { clearAll(); } } else { // Reset the maximum known value of an index maxIndex = intialIndexOffset + elementIndexes.length + attributeIndexes.length; // Check if there is enough free space // If overflow if ((indexOffset + maxIndex) < 0) { resetAll(); } } }
@Override public void beginStartTag(int prefix, String localName) throws IOException { fiout.writeLowLevelTerminationAndMark(); int type = EncodingConstants.ELEMENT; if (nsContext.getCurrent().count() > 0) { final NamespaceContextImpl.Element nse = nsContext.getCurrent(); fiout.writeLowLevelStartNamespaces(); for (int i = nse.count() - 1; i >= 0; i--) { final String uri = nse.getNsUri(i); if (uri.length() == 0 && nse.getBase() == 1) continue; // no point in definint xmlns='' on the root fiout.writeLowLevelNamespace(nse.getPrefix(i), uri); } fiout.writeLowLevelEndNamespaces(); type= 0; } final boolean isIndexed = fiout.writeLowLevelStartElement( type, nsContext.getPrefix(prefix), localName, nsContext.getNamespaceURI(prefix)); if (!isIndexed) tables.incrementMaxIndexValue(); }
public FastInfosetStreamWriterOutput(StAXDocumentSerializer out, JAXBContextImpl context) { super(out); this.fiout = out; this.localNames = context.getUTF8NameTable(); final VocabularyApplicationData vocabAppData = fiout.getVocabularyApplicationData(); AppData appData = null; if (vocabAppData == null || !(vocabAppData instanceof AppData)) { appData = new AppData(); fiout.setVocabularyApplicationData(appData); } else { appData = (AppData)vocabAppData; } final TablesPerJAXBContext tablesPerContext = appData.contexts.get(context); if (tablesPerContext != null) { tables = tablesPerContext; /** * Obtain the current local name index. Thus will be used to * calculate the maximum index value when serializing for this context */ tables.clearOrResetTables(out.getLocalNameIndex()); } else { tables = new TablesPerJAXBContext(context, out.getLocalNameIndex()); appData.contexts.put(context, tables); } }
@Override public void attribute(int prefix, String localName, String value) throws IOException { fiout.writeLowLevelStartAttributes(); boolean isIndexed; if (prefix == -1) isIndexed = fiout.writeLowLevelAttribute("", "", localName); else isIndexed = fiout.writeLowLevelAttribute( nsContext.getPrefix(prefix), nsContext.getNamespaceURI(prefix), localName); if (!isIndexed) tables.incrementMaxIndexValue(); fiout.writeLowLevelAttributeValue(value); } }
@Override public void attribute(int prefix, String localName, String value) throws IOException { fiout.writeLowLevelStartAttributes(); boolean isIndexed; if (prefix == -1) isIndexed = fiout.writeLowLevelAttribute("", "", localName); else isIndexed = fiout.writeLowLevelAttribute( nsContext.getPrefix(prefix), nsContext.getNamespaceURI(prefix), localName); if (!isIndexed) tables.incrementMaxIndexValue(); fiout.writeLowLevelAttributeValue(value); } }
/** * Increment the maximum know index value * <p> * The indexes are preserved. */ public void incrementMaxIndexValue() { // Increment the maximum value of an index maxIndex++; // Check if there is enough free space // If overflow if ((indexOffset + maxIndex) < 0) { resetAll(); } }
/** * Increment the maximum know index value * <p> * The indexes are preserved. */ public void incrementMaxIndexValue() { // Increment the maximum value of an index maxIndex++; // Check if there is enough free space // If overflow if ((indexOffset + maxIndex) < 0) { resetAll(); } }
/** * Clear all the tables. */ public void clear() { for(TablesPerJAXBContext c : collectionOfContexts) c.requireClearTables(); } }
/** * Clear all the tables. */ public void clear() { for(TablesPerJAXBContext c : collectionOfContexts) c.requireClearTables(); } }
@Override public void beginStartTag(int prefix, String localName) throws IOException { fiout.writeLowLevelTerminationAndMark(); int type = EncodingConstants.ELEMENT; if (nsContext.getCurrent().count() > 0) { final NamespaceContextImpl.Element nse = nsContext.getCurrent(); fiout.writeLowLevelStartNamespaces(); for (int i = nse.count() - 1; i >= 0; i--) { final String uri = nse.getNsUri(i); if (uri.length() == 0 && nse.getBase() == 1) continue; // no point in definint xmlns='' on the root fiout.writeLowLevelNamespace(nse.getPrefix(i), uri); } fiout.writeLowLevelEndNamespaces(); type= 0; } final boolean isIndexed = fiout.writeLowLevelStartElement( type, nsContext.getPrefix(prefix), localName, nsContext.getNamespaceURI(prefix)); if (!isIndexed) tables.incrementMaxIndexValue(); }
/** * Clear or reset the tables. * <p> * @param intialIndexOffset the initial index offset to calculate * the maximum possible index */ public void clearOrResetTables(int intialIndexOffset) { if (requiresClear) { requiresClear = false; // Increment offset to new position indexOffset += maxIndex; // Reset the maximum known value of an index maxIndex = intialIndexOffset + elementIndexes.length + attributeIndexes.length; // Check if there is enough free space // If overflow if ((indexOffset + maxIndex) < 0) { clearAll(); } } else { // Reset the maximum known value of an index maxIndex = intialIndexOffset + elementIndexes.length + attributeIndexes.length; // Check if there is enough free space // If overflow if ((indexOffset + maxIndex) < 0) { resetAll(); } } }