Examples of CreoleParseException


Examples of com.admc.jcreole.CreoleParseException

        String name;
        while ((offset2 = buffer.indexOf("\u0002", offset3 + 1)) > -1) {
            // Load Entries (without data)
            offsetNl = buffer.indexOf("\n", offset2 + 2);
            if (offsetNl < 0)
                throw new CreoleParseException("No name termination for Entry");
            // Unfortunately StringBuilder has no indexOf(char).
            // We could do StringBuilder.toString().indexOf(char), but
            // that's a pretty expensive copy operation.
            offset3 = buffer.indexOf("\u0003", offsetNl + 1);
            if (offset3 < 0)
                throw new CreoleParseException("No termination for Entry");
            name = buffer.substring(offset2 + 2, offsetNl);
            if (name.length() < 1)
                throw new CreoleParseException("Empty embedded name for Entry");
            switch (buffer.charAt(offset2 + 1)) {
              case 'D':
                eType = EntryType.MASTERDEF;
                break;
              case 'F':
                eType = EntryType.FOOTNOTE;
                break;
              default:
                throw new CreoleParseException(
                        "Unexpected EntryType indicator: "
                        + buffer.charAt(offset2 + 1));
            }
            if (footNotesMarker != null && eType == EntryType.FOOTNOTE) {
                footNotesMarker.add(name);
            } else if (masterDefListMarker != null
                    && eType == EntryType.MASTERDEF) {
                masterDefListMarker.add(name);
            }
        }

        if (footNotesMarker != null) {
            footNotesMarker.sort();
            footNotesMarker.updateReferences();
        }
        if (masterDefListMarker != null) {
            masterDefListMarker.sort();
            masterDefListMarker.updateReferences();
        }
        if (indexMarker != null) {
            indexMarker.generateEntries();
            indexMarker.sort();
        }

        forwardPass2(sortedMarkers);
        log.debug(Integer.toString(sections.size())
                + " Section headings: " + sections);
        // The list of markers MUST BE REVERSE SORTED before applying.
        // Applying in forward order would change buffer offsets.
        Collections.reverse(sortedMarkers);
        for (BufferMarker m : sortedMarkers)
            // N.b. this is where the real APPLY occurs to the buffer:
            if (!(m instanceof BodyUpdaterMarker)) m.updateBuffer();

        // Can not move Entries until all of the normal \u001a markers have
        // been taken care of, because Styler directives depend on original
        // Creole sequence.

        // Extract all Entries
        offset2 = 0;
        while ((offset2 = buffer.indexOf("\u0002", offset2)) > -1) {
            // Load data for Entries
            offsetNl = buffer.indexOf("\n", offset2 + 2);
            if (offsetNl < 0)
                throw new CreoleParseException("No name termination for Entry");
            // Unfortunately StringBuilder has no indexOf(char).
            // We could do StringBuilder.toString().indexOf(char), but
            // that's a pretty expensive copy operation.
            offset3 = buffer.indexOf("\u0003", offsetNl + 1);
            if (offset3 < 0)
                throw new CreoleParseException("No termination for Entry");
            name = buffer.substring(offset2 + 2, offsetNl);
            if (name.length() < 1)
                throw new CreoleParseException("Empty embedded name for Entry");
            switch (buffer.charAt(offset2 + 1)) {
              case 'D':
                eType = EntryType.MASTERDEF;
                break;
              case 'F':
                eType = EntryType.FOOTNOTE;
                break;
              default:
                throw new CreoleParseException(
                        "Unexpected EntryType indicator: "
                        + buffer.charAt(offset2 + 1));
            }
            if (footNotesMarker != null
                    && eType == EntryType.FOOTNOTE)
View Full Code Here

Examples of com.admc.jcreole.CreoleParseException

        while ((offset = buffer.indexOf("\u001a", offset)) > -1) try {
            // Unfortunately StringBuilder has no indexOf(char).
            // We could do StringBuilder.toString().indexOf(char), but
            // that's a pretty expensive copy operation.
            if (buffer.length() < offset + 4)
                throw new CreoleParseException(
                        "Marking too close to end of output");
            idString = buffer.substring(offset + 1, offset + 5);
            id = Integer.parseInt(idString, 16);
            marker = get(Integer.valueOf(id));
            if (marker == null)
View Full Code Here

Examples of com.admc.jcreole.CreoleParseException

                    break;
                  default:
                    throw new IllegalStateException(
                            "Unexpected target tag type: " + targetType);
                } } catch (Exception e) {
                    throw new CreoleParseException(
                            "Tangled tag nesting.  No matching open "
                            + targetType + " tag for close of "
                            + closeM + ".  Last open tag is "
                            + lastTag + '.', e);
                }
                if (lastTag.isAtomic())
                    throw new CreoleParseException(
                            "Close tag " + closeM
                            + " attempted to close atomic tag "
                            + lastTag + '.');
                // Get this validation over with so rest of this block can
                // assume lastTag is an instance of one of these types.
                if (!(lastTag instanceof JcxSpanMarker)
                        && !(lastTag instanceof JcxBlockMarker)
                        && !(lastTag instanceof BlockMarker)
                        && !(lastTag instanceof InlineMarker))
                    throw new RuntimeException(
                            "Unexpected class for TagMarker " + lastTag
                            + ": " + lastTag.getClass().getName());
                // At this point we have validated match with an opening tag.
                if (lastTag instanceof JcxSpanMarker) {
                    prevJcxSpan = (JcxSpanMarker) lastTag;
                    typedStack = jcxSpanStack;
                } else if (lastTag instanceof JcxBlockMarker) {
                    prevJcxBlock = (JcxBlockMarker) lastTag;
                    typedStack = jcxBlockStack;
                } else if (lastTag instanceof BlockMarker) {
                    prevBlock = (BlockMarker) lastTag;
                    typedStack = blockStack;
                } else if (lastTag instanceof InlineMarker) {
                    prevInline = (InlineMarker) lastTag;
                    typedStack = inlineStack;
                }
                if (typedStack.size() < 1 || typedStack.get(0) != lastTag)
                    throw new CreoleParseException(
                            "Closing tag " + lastTag
                            + ", but it is not on the tail of the "
                            + "type-specific tag stack: " + typedStack);
                typedStack.remove(0);
                stack.remove(0);
            } else if (m instanceof Styler) {
                Styler styler = (Styler) m;
                TagType targetType = styler.getTargetType();
                String[] classNames = styler.getClassNames();
                // Get this validation over with so rest of this block can
                // assume targetType is an instance of one of these types.
                switch (targetType) {
                  case INLINE:
                  case BLOCK:
                  case JCXSPAN:
                  case JCXBLOCK:
                    break;
                  default:
                    throw new RuntimeException(
                            "Unexpected tag type value: " + targetType);
                }
                TagMarker targetTag = null;
                switch (styler.getTargetDirection()) {
                  case PREVIOUS:
                    switch (targetType) {
                      case INLINE:
                        targetTag = prevInline;
                        break;
                      case BLOCK:
                        targetTag = prevBlock;
                        break;
                      case JCXSPAN:
                        targetTag = prevJcxSpan;
                        break;
                      case JCXBLOCK:
                        targetTag = prevJcxBlock;
                        break;
                    }
                    if (targetTag == null)
                        throw new CreoleParseException(
                                "No previous " + targetType
                                + " tag for Styler " + styler);
                    break;
                  case CONTAINER:
                    switch (targetType) {
                      case INLINE:
                        typedStack = inlineStack;
                        break;
                      case BLOCK:
                        typedStack = blockStack;
                        break;
                      case JCXSPAN:
                        typedStack = jcxSpanStack;
                        break;
                      case JCXBLOCK:
                        typedStack = jcxBlockStack;
                        break;
                    }
                    if (typedStack.size() < 1)
                        throw new CreoleParseException(
                                "No parent " + targetType
                                + " container for Styler " + styler);
                    targetTag = typedStack.get(0);
                    break;
                  case NEXT:
                    switch (targetType) {
                      case INLINE:
                        typedQueue = queuedInlineClassNames;
                        break;
                      case BLOCK:
                        typedQueue = queuedBlockClassNames;
                        break;
                      case JCXSPAN:
                        typedQueue = queuedJcxSpanClassNames;
                        break;
                      case JCXBLOCK:
                        typedQueue = queuedJcxBlockClassNames;
                        break;
                    }
                    typedQueue.addAll(Arrays.asList(classNames));
                    break;
                  default:
                    throw new RuntimeException("Unexpected direction value: "
                            + styler.getTargetDirection());
                }
                if (targetTag != null) targetTag.addCssClasses(classNames);
            } else if (m instanceof LinkMarker) {
                linkM = (LinkMarker) m;
                linkText = linkM.getLinkText();
                String lookedUpLabel =
                        idToTextHMap.get(linkM.getLinkText().substring(1));
                if (linkM.getLabel() == null)
                    linkM.setLabel((lookedUpLabel == null)
                            ? linkM.getLinkText()
                            : lookedUpLabel);
                if (lookedUpLabel == null)
                    linkM.wrapLabel(
                            "<span class=\"jcreole_orphanLink\">", "</span>");
            } else if (m instanceof TocMarker) {
                ((TocMarker) m).setSectionHeadings(sections);
            } else if (m instanceof BodyUpdaterMarker) {
                ;
            } else if (m instanceof FootNoteRefMarker) {
                ;
            } else if (m instanceof IndexedMarker) {
                ;
            } else if (m instanceof DeferredUrlMarker) {
                ;
            } else {
                throw new CreoleParseException(
                        "Unexpected close marker class: "
                        + m.getClass().getName());
            }
            if (m instanceof HeadingMarker) {
                headingM = (HeadingMarker) m;
                SectionHeading sh = headingM.getSectionHeading();
                enumerationFormats =
                        headingM.updatedEnumerationFormats(enumerationFormats);
                sh.setEnumerationFormats(enumerationFormats);
                sections.add(sh);
                int newLevel = sh.getLevel();
                if (newLevel > headingLevel) {
                    headingLevel = newLevel;
                } else if (newLevel < headingLevel) {
                    for (int i = headingLevel; i > newLevel; i--)
                        curSequences[i-1] = -1;
                    headingLevel = newLevel;
                } else {
                    // No level change
                    // Intentionally empty
                }
                if (headingM.getFormatReset() != null)
                    curSequences[headingLevel-1] = -1;
                curSequences[headingLevel-1] += 1;
                sh.setSequences(curSequences);
            }
        }
        if (stack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched tag(s) generated: " + stack);
        if (jcxSpanStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched JCX Span tag(s): " + jcxSpanStack);
        if (blockStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched Block tag(s): " + blockStack);
        if (jcxBlockStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched JCX Block tag(s): " + jcxBlockStack);
        if (inlineStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched Inline tag(s): " + inlineStack);
        if (queuedJcxSpanClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler JCX class names: "
                    + queuedJcxSpanClassNames);
        if (queuedJcxBlockClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler JCX Block class names: "
                    + queuedBlockClassNames);
        if (queuedBlockClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler Block class names: "
                    + queuedBlockClassNames);
        if (queuedInlineClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler Inline class names: "
                    + queuedInlineClassNames);
    }
View Full Code Here

Examples of com.admc.jcreole.CreoleParseException

        String name;
        while ((offset2 = buffer.indexOf("\u0002", offset3 + 1)) > -1) {
            // Load Entries (without data)
            offsetNl = buffer.indexOf("\n", offset2 + 2);
            if (offsetNl < 0)
                throw new CreoleParseException("No name termination for Entry");
            // Unfortunately StringBuilder has no indexOf(char).
            // We could do StringBuilder.toString().indexOf(char), but
            // that's a pretty expensive copy operation.
            offset3 = buffer.indexOf("\u0003", offsetNl + 1);
            if (offset3 < 0)
                throw new CreoleParseException("No termination for Entry");
            name = buffer.substring(offset2 + 2, offsetNl);
            if (name.length() < 1)
                throw new CreoleParseException("Empty embedded name for Entry");
            switch (buffer.charAt(offset2 + 1)) {
              case 'D':
                eType = EntryType.MASTERDEF;
                break;
              case 'F':
                eType = EntryType.FOOTNOTE;
                break;
              default:
                throw new CreoleParseException(
                        "Unexpected EntryType indicator: "
                        + buffer.charAt(offset2 + 1));
            }
            if (footNotesMarker != null && eType == EntryType.FOOTNOTE) {
                footNotesMarker.add(name);
            } else if (masterDefListMarker != null
                    && eType == EntryType.MASTERDEF) {
                masterDefListMarker.add(name);
            }
        }

        if (footNotesMarker != null) {
            footNotesMarker.sort();
            footNotesMarker.updateReferences();
        }
        if (masterDefListMarker != null) {
            masterDefListMarker.sort();
            masterDefListMarker.updateReferences();
        }
        if (indexMarker != null) {
            indexMarker.generateEntries();
            indexMarker.sort();
        }

        forwardPass2(sortedMarkers);
        log.debug(Integer.toString(sections.size())
                + " Section headings: " + sections);
        // The list of markers MUST BE REVERSE SORTED before applying.
        // Applying in forward order would change buffer offsets.
        Collections.reverse(sortedMarkers);
        for (BufferMarker m : sortedMarkers)
            // N.b. this is where the real APPLY occurs to the buffer:
            if (!(m instanceof BodyUpdaterMarker)) m.updateBuffer();

        // Can not move Entries until all of the normal \u001a markers have
        // been taken care of, because Styler directives depend on original
        // Creole sequence.

        // Extract all Entries
        offset2 = 0;
        while ((offset2 = buffer.indexOf("\u0002", offset2)) > -1) {
            // Load data for Entries
            offsetNl = buffer.indexOf("\n", offset2 + 2);
            if (offsetNl < 0)
                throw new CreoleParseException("No name termination for Entry");
            // Unfortunately StringBuilder has no indexOf(char).
            // We could do StringBuilder.toString().indexOf(char), but
            // that's a pretty expensive copy operation.
            offset3 = buffer.indexOf("\u0003", offsetNl + 1);
            if (offset3 < 0)
                throw new CreoleParseException("No termination for Entry");
            name = buffer.substring(offset2 + 2, offsetNl);
            if (name.length() < 1)
                throw new CreoleParseException("Empty embedded name for Entry");
            switch (buffer.charAt(offset2 + 1)) {
              case 'D':
                eType = EntryType.MASTERDEF;
                break;
              case 'F':
                eType = EntryType.FOOTNOTE;
                break;
              default:
                throw new CreoleParseException(
                        "Unexpected EntryType indicator: "
                        + buffer.charAt(offset2 + 1));
            }
            if (footNotesMarker != null
                    && eType == EntryType.FOOTNOTE)
View Full Code Here

Examples of com.admc.jcreole.CreoleParseException

        while ((offset = buffer.indexOf("\u001a", offset)) > -1) try {
            // Unfortunately StringBuilder has no indexOf(char).
            // We could do StringBuilder.toString().indexOf(char), but
            // that's a pretty expensive copy operation.
            if (buffer.length() < offset + 4)
                throw new CreoleParseException(
                        "Marking too close to end of output");
            idString = buffer.substring(offset + 1, offset + 5);
            id = Integer.parseInt(idString, 16);
            marker = get(Integer.valueOf(id));
            if (marker == null)
View Full Code Here

Examples of com.admc.jcreole.CreoleParseException

                    break;
                  default:
                    throw new IllegalStateException(
                            "Unexpected target tag type: " + targetType);
                } } catch (Exception e) {
                    throw new CreoleParseException(
                            "Tangled tag nesting.  No matching open "
                            + targetType + " tag for close of "
                            + closeM + ".  Last open tag is "
                            + lastTag + '.', e);
                }
                if (lastTag.isAtomic())
                    throw new CreoleParseException(
                            "Close tag " + closeM
                            + " attempted to close atomic tag "
                            + lastTag + '.');
                // Get this validation over with so rest of this block can
                // assume lastTag is an instance of one of these types.
                if (!(lastTag instanceof JcxSpanMarker)
                        && !(lastTag instanceof JcxBlockMarker)
                        && !(lastTag instanceof BlockMarker)
                        && !(lastTag instanceof InlineMarker))
                    throw new RuntimeException(
                            "Unexpected class for TagMarker " + lastTag
                            + ": " + lastTag.getClass().getName());
                // At this point we have validated match with an opening tag.
                if (lastTag instanceof JcxSpanMarker) {
                    prevJcxSpan = (JcxSpanMarker) lastTag;
                    typedStack = jcxSpanStack;
                } else if (lastTag instanceof JcxBlockMarker) {
                    prevJcxBlock = (JcxBlockMarker) lastTag;
                    typedStack = jcxBlockStack;
                } else if (lastTag instanceof BlockMarker) {
                    prevBlock = (BlockMarker) lastTag;
                    typedStack = blockStack;
                } else if (lastTag instanceof InlineMarker) {
                    prevInline = (InlineMarker) lastTag;
                    typedStack = inlineStack;
                }
                if (typedStack.size() < 1 || typedStack.get(0) != lastTag)
                    throw new CreoleParseException(
                            "Closing tag " + lastTag
                            + ", but it is not on the tail of the "
                            + "type-specific tag stack: " + typedStack);
                typedStack.remove(0);
                stack.remove(0);
            } else if (m instanceof Styler) {
                Styler styler = (Styler) m;
                TagType targetType = styler.getTargetType();
                String[] classNames = styler.getClassNames();
                // Get this validation over with so rest of this block can
                // assume targetType is an instance of one of these types.
                switch (targetType) {
                  case INLINE:
                  case BLOCK:
                  case JCXSPAN:
                  case JCXBLOCK:
                    break;
                  default:
                    throw new RuntimeException(
                            "Unexpected tag type value: " + targetType);
                }
                TagMarker targetTag = null;
                switch (styler.getTargetDirection()) {
                  case PREVIOUS:
                    switch (targetType) {
                      case INLINE:
                        targetTag = prevInline;
                        break;
                      case BLOCK:
                        targetTag = prevBlock;
                        break;
                      case JCXSPAN:
                        targetTag = prevJcxSpan;
                        break;
                      case JCXBLOCK:
                        targetTag = prevJcxBlock;
                        break;
                    }
                    if (targetTag == null)
                        throw new CreoleParseException(
                                "No previous " + targetType
                                + " tag for Styler " + styler);
                    break;
                  case CONTAINER:
                    switch (targetType) {
                      case INLINE:
                        typedStack = inlineStack;
                        break;
                      case BLOCK:
                        typedStack = blockStack;
                        break;
                      case JCXSPAN:
                        typedStack = jcxSpanStack;
                        break;
                      case JCXBLOCK:
                        typedStack = jcxBlockStack;
                        break;
                    }
                    if (typedStack.size() < 1)
                        throw new CreoleParseException(
                                "No parent " + targetType
                                + " container for Styler " + styler);
                    targetTag = typedStack.get(0);
                    break;
                  case NEXT:
                    switch (targetType) {
                      case INLINE:
                        typedQueue = queuedInlineClassNames;
                        break;
                      case BLOCK:
                        typedQueue = queuedBlockClassNames;
                        break;
                      case JCXSPAN:
                        typedQueue = queuedJcxSpanClassNames;
                        break;
                      case JCXBLOCK:
                        typedQueue = queuedJcxBlockClassNames;
                        break;
                    }
                    typedQueue.addAll(Arrays.asList(classNames));
                    break;
                  default:
                    throw new RuntimeException("Unexpected direction value: "
                            + styler.getTargetDirection());
                }
                if (targetTag != null) targetTag.addCssClasses(classNames);
            } else if (m instanceof LinkMarker) {
                linkM = (LinkMarker) m;
                linkText = linkM.getLinkText();
                String lookedUpLabel =
                        idToTextHMap.get(linkM.getLinkText().substring(1));
                if (linkM.getLabel() == null)
                    linkM.setLabel((lookedUpLabel == null)
                            ? linkM.getLinkText()
                            : lookedUpLabel);
                if (lookedUpLabel == null)
                    linkM.wrapLabel(
                            "<span class=\"jcreole_orphanLink\">", "</span>");
            } else if (m instanceof TocMarker) {
                ((TocMarker) m).setSectionHeadings(sections);
            } else if (m instanceof BodyUpdaterMarker) {
                ;
            } else if (m instanceof FootNoteRefMarker) {
                ;
            } else if (m instanceof IndexedMarker) {
                ;
            } else if (m instanceof DeferredUrlMarker) {
                ;
            } else {
                throw new CreoleParseException(
                        "Unexpected close marker class: "
                        + m.getClass().getName());
            }
            if (m instanceof HeadingMarker) {
                headingM = (HeadingMarker) m;
                SectionHeading sh = headingM.getSectionHeading();
                enumerationFormats =
                        headingM.updatedEnumerationFormats(enumerationFormats);
                sh.setEnumerationFormats(enumerationFormats);
                sections.add(sh);
                int newLevel = sh.getLevel();
                if (newLevel > headingLevel) {
                    headingLevel = newLevel;
                } else if (newLevel < headingLevel) {
                    for (int i = headingLevel; i > newLevel; i--)
                        curSequences[i-1] = -1;
                    headingLevel = newLevel;
                } else {
                    // No level change
                    // Intentionally empty
                }
                if (headingM.getFormatReset() != null)
                    curSequences[headingLevel-1] = -1;
                curSequences[headingLevel-1] += 1;
                sh.setSequences(curSequences);
            }
        }
        if (stack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched tag(s) generated: " + stack);
        if (jcxSpanStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched JCX Span tag(s): " + jcxSpanStack);
        if (blockStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched Block tag(s): " + blockStack);
        if (jcxBlockStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched JCX Block tag(s): " + jcxBlockStack);
        if (inlineStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched Inline tag(s): " + inlineStack);
        if (queuedJcxSpanClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler JCX class names: "
                    + queuedJcxSpanClassNames);
        if (queuedJcxBlockClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler JCX Block class names: "
                    + queuedBlockClassNames);
        if (queuedBlockClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler Block class names: "
                    + queuedBlockClassNames);
        if (queuedInlineClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler Inline class names: "
                    + queuedInlineClassNames);
    }
View Full Code Here

Examples of com.admc.jcreole.CreoleParseException

        String name;
        while ((offset2 = buffer.indexOf("\u0002", offset3 + 1)) > -1) {
            // Load Entries (without data)
            offsetNl = buffer.indexOf("\n", offset2 + 2);
            if (offsetNl < 0)
                throw new CreoleParseException("No name termination for Entry");
            // Unfortunately StringBuilder has no indexOf(char).
            // We could do StringBuilder.toString().indexOf(char), but
            // that's a pretty expensive copy operation.
            offset3 = buffer.indexOf("\u0003", offsetNl + 1);
            if (offset3 < 0)
                throw new CreoleParseException("No termination for Entry");
            name = buffer.substring(offset2 + 2, offsetNl);
            if (name.length() < 1)
                throw new CreoleParseException("Empty embedded name for Entry");
            switch (buffer.charAt(offset2 + 1)) {
              case 'D':
                eType = EntryType.MASTERDEF;
                break;
              case 'F':
                eType = EntryType.FOOTNOTE;
                break;
              default:
                throw new CreoleParseException(
                        "Unexpected EntryType indicator: "
                        + buffer.charAt(offset2 + 1));
            }
            if (footNotesMarker != null && eType == EntryType.FOOTNOTE) {
                footNotesMarker.add(name);
            } else if (masterDefListMarker != null
                    && eType == EntryType.MASTERDEF) {
                masterDefListMarker.add(name);
            }
        }

        if (footNotesMarker != null) {
            footNotesMarker.sort();
            footNotesMarker.updateReferences();
        }
        if (masterDefListMarker != null) {
            masterDefListMarker.sort();
            masterDefListMarker.updateReferences();
        }
        if (indexMarker != null) {
            indexMarker.generateEntries();
            indexMarker.sort();
        }

        forwardPass2(sortedMarkers);
        log.debug(Integer.toString(sections.size())
                + " Section headings: " + sections);
        // The list of markers MUST BE REVERSE SORTED before applying.
        // Applying in forward order would change buffer offsets.
        Collections.reverse(sortedMarkers);
        for (BufferMarker m : sortedMarkers)
            // N.b. this is where the real APPLY occurs to the buffer:
            if (!(m instanceof BodyUpdaterMarker)) m.updateBuffer();

        // Can not move Entries until all of the normal \u001a markers have
        // been taken care of, because Styler directives depend on original
        // Creole sequence.

        // Extract all Entries
        offset2 = 0;
        while ((offset2 = buffer.indexOf("\u0002", offset2)) > -1) {
            // Load data for Entries
            offsetNl = buffer.indexOf("\n", offset2 + 2);
            if (offsetNl < 0)
                throw new CreoleParseException("No name termination for Entry");
            // Unfortunately StringBuilder has no indexOf(char).
            // We could do StringBuilder.toString().indexOf(char), but
            // that's a pretty expensive copy operation.
            offset3 = buffer.indexOf("\u0003", offsetNl + 1);
            if (offset3 < 0)
                throw new CreoleParseException("No termination for Entry");
            name = buffer.substring(offset2 + 2, offsetNl);
            if (name.length() < 1)
                throw new CreoleParseException("Empty embedded name for Entry");
            switch (buffer.charAt(offset2 + 1)) {
              case 'D':
                eType = EntryType.MASTERDEF;
                break;
              case 'F':
                eType = EntryType.FOOTNOTE;
                break;
              default:
                throw new CreoleParseException(
                        "Unexpected EntryType indicator: "
                        + buffer.charAt(offset2 + 1));
            }
            if (footNotesMarker != null
                    && eType == EntryType.FOOTNOTE)
View Full Code Here

Examples of com.admc.jcreole.CreoleParseException

        while ((offset = buffer.indexOf("\u001a", offset)) > -1) try {
            // Unfortunately StringBuilder has no indexOf(char).
            // We could do StringBuilder.toString().indexOf(char), but
            // that's a pretty expensive copy operation.
            if (buffer.length() < offset + 4)
                throw new CreoleParseException(
                        "Marking too close to end of output");
            idString = buffer.substring(offset + 1, offset + 5);
            id = Integer.parseInt(idString, 16);
            marker = get(Integer.valueOf(id));
            if (marker == null)
View Full Code Here

Examples of com.admc.jcreole.CreoleParseException

                    break;
                  default:
                    throw new IllegalStateException(
                            "Unexpected target tag type: " + targetType);
                } } catch (Exception e) {
                    throw new CreoleParseException(
                            "Tangled tag nesting.  No matching open "
                            + targetType + " tag for close of "
                            + closeM + ".  Last open tag is "
                            + lastTag + '.', e);
                }
                if (lastTag.isAtomic())
                    throw new CreoleParseException(
                            "Close tag " + closeM
                            + " attempted to close atomic tag "
                            + lastTag + '.');
                // Get this validation over with so rest of this block can
                // assume lastTag is an instance of one of these types.
                if (!(lastTag instanceof JcxSpanMarker)
                        && !(lastTag instanceof JcxBlockMarker)
                        && !(lastTag instanceof BlockMarker)
                        && !(lastTag instanceof InlineMarker))
                    throw new RuntimeException(
                            "Unexpected class for TagMarker " + lastTag
                            + ": " + lastTag.getClass().getName());
                // At this point we have validated match with an opening tag.
                if (lastTag instanceof JcxSpanMarker) {
                    prevJcxSpan = (JcxSpanMarker) lastTag;
                    typedStack = jcxSpanStack;
                } else if (lastTag instanceof JcxBlockMarker) {
                    prevJcxBlock = (JcxBlockMarker) lastTag;
                    typedStack = jcxBlockStack;
                } else if (lastTag instanceof BlockMarker) {
                    prevBlock = (BlockMarker) lastTag;
                    typedStack = blockStack;
                } else if (lastTag instanceof InlineMarker) {
                    prevInline = (InlineMarker) lastTag;
                    typedStack = inlineStack;
                }
                if (typedStack.size() < 1 || typedStack.get(0) != lastTag)
                    throw new CreoleParseException(
                            "Closing tag " + lastTag
                            + ", but it is not on the tail of the "
                            + "type-specific tag stack: " + typedStack);
                typedStack.remove(0);
                stack.remove(0);
            } else if (m instanceof Styler) {
                Styler styler = (Styler) m;
                TagType targetType = styler.getTargetType();
                String[] classNames = styler.getClassNames();
                // Get this validation over with so rest of this block can
                // assume targetType is an instance of one of these types.
                switch (targetType) {
                  case INLINE:
                  case BLOCK:
                  case JCXSPAN:
                  case JCXBLOCK:
                    break;
                  default:
                    throw new RuntimeException(
                            "Unexpected tag type value: " + targetType);
                }
                TagMarker targetTag = null;
                switch (styler.getTargetDirection()) {
                  case PREVIOUS:
                    switch (targetType) {
                      case INLINE:
                        targetTag = prevInline;
                        break;
                      case BLOCK:
                        targetTag = prevBlock;
                        break;
                      case JCXSPAN:
                        targetTag = prevJcxSpan;
                        break;
                      case JCXBLOCK:
                        targetTag = prevJcxBlock;
                        break;
                    }
                    if (targetTag == null)
                        throw new CreoleParseException(
                                "No previous " + targetType
                                + " tag for Styler " + styler);
                    break;
                  case CONTAINER:
                    switch (targetType) {
                      case INLINE:
                        typedStack = inlineStack;
                        break;
                      case BLOCK:
                        typedStack = blockStack;
                        break;
                      case JCXSPAN:
                        typedStack = jcxSpanStack;
                        break;
                      case JCXBLOCK:
                        typedStack = jcxBlockStack;
                        break;
                    }
                    if (typedStack.size() < 1)
                        throw new CreoleParseException(
                                "No parent " + targetType
                                + " container for Styler " + styler);
                    targetTag = typedStack.get(0);
                    break;
                  case NEXT:
                    switch (targetType) {
                      case INLINE:
                        typedQueue = queuedInlineClassNames;
                        break;
                      case BLOCK:
                        typedQueue = queuedBlockClassNames;
                        break;
                      case JCXSPAN:
                        typedQueue = queuedJcxSpanClassNames;
                        break;
                      case JCXBLOCK:
                        typedQueue = queuedJcxBlockClassNames;
                        break;
                    }
                    typedQueue.addAll(Arrays.asList(classNames));
                    break;
                  default:
                    throw new RuntimeException("Unexpected direction value: "
                            + styler.getTargetDirection());
                }
                if (targetTag != null) targetTag.addCssClasses(classNames);
            } else if (m instanceof LinkMarker) {
                linkM = (LinkMarker) m;
                linkText = linkM.getLinkText();
                String lookedUpLabel =
                        idToTextHMap.get(linkM.getLinkText().substring(1));
                if (linkM.getLabel() == null)
                    linkM.setLabel((lookedUpLabel == null)
                            ? linkM.getLinkText()
                            : lookedUpLabel);
                if (lookedUpLabel == null)
                    linkM.wrapLabel(
                            "<span class=\"jcreole_orphanLink\">", "</span>");
            } else if (m instanceof TocMarker) {
                ((TocMarker) m).setSectionHeadings(sections);
            } else if (m instanceof BodyUpdaterMarker) {
                ;
            } else if (m instanceof FootNoteRefMarker) {
                ;
            } else if (m instanceof IndexedMarker) {
                ;
            } else if (m instanceof DeferredUrlMarker) {
                ;
            } else {
                throw new CreoleParseException(
                        "Unexpected close marker class: "
                        + m.getClass().getName());
            }
            if (m instanceof HeadingMarker) {
                headingM = (HeadingMarker) m;
                SectionHeading sh = headingM.getSectionHeading();
                enumerationFormats =
                        headingM.updatedEnumerationFormats(enumerationFormats);
                sh.setEnumerationFormats(enumerationFormats);
                sections.add(sh);
                int newLevel = sh.getLevel();
                if (newLevel > headingLevel) {
                    headingLevel = newLevel;
                } else if (newLevel < headingLevel) {
                    for (int i = headingLevel; i > newLevel; i--)
                        curSequences[i-1] = -1;
                    headingLevel = newLevel;
                } else {
                    // No level change
                    // Intentionally empty
                }
                if (headingM.getFormatReset() != null)
                    curSequences[headingLevel-1] = -1;
                curSequences[headingLevel-1] += 1;
                sh.setSequences(curSequences);
            }
        }
        if (stack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched tag(s) generated: " + stack);
        if (jcxSpanStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched JCX Span tag(s): " + jcxSpanStack);
        if (blockStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched Block tag(s): " + blockStack);
        if (jcxBlockStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched JCX Block tag(s): " + jcxBlockStack);
        if (inlineStack.size() != 0)
            throw new CreoleParseException(
                    "Unmatched Inline tag(s): " + inlineStack);
        if (queuedJcxSpanClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler JCX class names: "
                    + queuedJcxSpanClassNames);
        if (queuedJcxBlockClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler JCX Block class names: "
                    + queuedBlockClassNames);
        if (queuedBlockClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler Block class names: "
                    + queuedBlockClassNames);
        if (queuedInlineClassNames.size() > 0)
            throw new CreoleParseException(
                    "Unapplied Styler Inline class names: "
                    + queuedInlineClassNames);
    }
View Full Code Here

Examples of com.admc.jcreole.CreoleParseException

    public FootNotesMarker(int id, EntryOrdering inOrdering) {
        super(id, (inOrdering == null) ? EntryOrdering.REF_ORDER : inOrdering);
        switch (ordering) {
          case NAME_BY_JAVA:
          case NAME_BY_DICTIONARY:
            throw new CreoleParseException(
                    "Ordering not supported for FootNotes: " + ordering);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.