Package net.java.textilej.util

Examples of net.java.textilej.util.LocationTrackingReader


  }
 
  public void processContent(MarkupParser parser, String markupContent, boolean asDocument) {
    ContentState state = createState();
    state.setMarkupContent(markupContent);
    LocationTrackingReader reader = new LocationTrackingReader(new StringReader(markupContent));
    String line;
    Block currentBlock = null;
   
    DocumentBuilder builder = parser.getBuilder();
   
    builder.setLocator(state);
    try {
      if (asDocument) {
        builder.beginDocument();
      }
     
      try {
        while ((line = reader.readLine()) != null) {
         
          state.setLineNumber(reader.getLineNumber()+1);
          state.setLineOffset(reader.getLineOffset());
          state.setLineCharacterOffset(0);
          state.setLineSegmentEndOffset(0);
          state.setLineLength(line.length());
         
          int lineOffset = 0;
          for (;;) {
            if (currentBlock == null) {
              currentBlock = startBlock(line,lineOffset);
              if (currentBlock == null) {
                break;
              }
              currentBlock.setState(state);
              currentBlock.setParser(parser);
            }
            lineOffset = currentBlock.processLineContent(line,lineOffset);
            if (currentBlock.isClosed()) {
              currentBlock = null;
            }
            if (lineOffset < line.length() && lineOffset >= 0) {
              if (currentBlock != null) {
                throw new IllegalStateException("if a block does not fully process a line then it must be closed");
              }
            } else {
              break;
            }
          }
        }
        state.setLineNumber(reader.getLineNumber()+1);
        state.setLineOffset(reader.getLineOffset());
        state.setLineCharacterOffset(0);
        state.setLineLength(0);
       
      } catch (IOException e) {
        throw new IllegalStateException(e);
View Full Code Here

TOP

Related Classes of net.java.textilej.util.LocationTrackingReader

Copyright © 2018 www.massapicom. 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.