/** * End the {@link DocumentPart} and finalize the {@link Event}. Place the {@link Event} on the event queue. */ public void endDocumentPart() { endDocumentPart(null); }
/** * Create a single {@link DocumentPart} and add a {@link DocumentPart} {@link Event} to the queue. * * @param part * the {@link DocumentPart} (aka skeleton) * @return the newly created DocumentPart */ public DocumentPart addDocumentPart(String part) { DocumentPart dp = startDocumentPart(part); endDocumentPart(); return dp; }
/** * Add the START_SUBDOCUMENT {@link Event} to the event queue. * @return the {@link StartSubDocument} created and added, * or null if there is no <code>subFilter</code> */ public StartSubDocument startSubDocument() { StartSubDocument startSubDocument = null; if (!subFilter) { if (hasUnfinishedSkeleton()) { endDocumentPart(); } startSubDocument = new StartSubDocument(subDocumentId.createId()); Event event = new Event(EventType.START_SUBDOCUMENT, startSubDocument); filterEvents.add(event); LOGGER.debug("Start Sub-Document for " + startSubDocument.getId()); } return startSubDocument; }
/** * Convert the skeleton attached to an in-progress {@link TextUnit} into * a {@link DocumentPart}. This is used when a TextUnit has been started * but then is immediately ended without any content. The final skeleton * part in the TU is always a self-reference, which is stripped during * the conversion. */ public void convertTempTextUnitToDocumentPart() { if (peekTempEvent().getEventType() != EventType.TEXT_UNIT) { return; } Event e = popTempEvent(); ITextUnit textUnit = (e.getTextUnit()); GenericSkeleton oldTuSkeleton = (GenericSkeleton)textUnit.getSkeleton(); if (oldTuSkeleton != null) { List<GenericSkeletonPart> parts = oldTuSkeleton.getParts(); // Skip the trailing [$$self$] reference StringBuilder sb = new StringBuilder(); for (int i = 0; i < parts.size() - 1; i++) { sb.append(parts.get(i).toString()); } addToDocumentPart(sb.toString()); endDocumentPart(); } }
/** * Flush all remaining events from the {@link Event} queues */ public void flushRemainingTempEvents() { if (hasUnfinishedSkeleton()) { endDocumentPart(); } else if (!tempFilterEventStack.isEmpty()) { // go through filtered object stack and close them one by one while (!tempFilterEventStack.isEmpty()) { Event fe = tempFilterEventStack.peek(); if (fe.getEventType() == EventType.START_GROUP) { StartGroup sg = (StartGroup) fe.getResource(); endGroup((GenericSkeleton) sg.getSkeleton()); } else if (fe.getEventType() == EventType.START_SUBFILTER) { StartSubfilter sf = (StartSubfilter) fe.getResource(); endGroup((GenericSkeleton) sf.getSkeleton()); } else if (fe.getEventType() == EventType.TEXT_UNIT) { endTextUnit(); } } } }
/** * Create a {@link DocumentPart} and store it for later processing. * * @param part * the {@link DocumentPart} (aka skeleton) * @return the newly created DocumentPart */ public DocumentPart startDocumentPart(String part) { if (hasUnfinishedSkeleton()) { endDocumentPart(); } else if (isCurrentTextUnit()) { endTextUnit(); } currentSkeleton = new GenericSkeleton(part); currentDocumentPart = new DocumentPart(documentPartId.createId(), false); currentDocumentPart.setSkeleton(currentSkeleton); return currentDocumentPart; }
/** * Create a {@link DocumentPart} that references actionable (i.e., translatable, localizable) properties and store * it for later processing. * * @param part * the {@link DocumentPart} (aka skeleton) * @param name * the name * @param locale * the language of any actionable items * @param propertyTextUnitPlaceholders * the list of actionable {@link TextUnit} or {@link Properties} with offset information into the tag. */ public void startDocumentPart(String part, String name, LocaleId locale, List<PropertyTextUnitPlaceholder> propertyTextUnitPlaceholders) { if (hasUnfinishedSkeleton()) { endDocumentPart(); } else if (isCurrentTextUnit()) { endTextUnit(); } currentSkeleton = new GenericSkeleton(); currentDocumentPart = new DocumentPart(documentPartId.createId(), false); currentDocumentPart.setSkeleton(currentSkeleton); processAllEmbedded(part, locale, propertyTextUnitPlaceholders, false); }
List<PropertyTextUnitPlaceholder> propertyTextUnitPlaceholders) { if (hasUnfinishedSkeleton()) { endDocumentPart();