@Test public void TestSingleTag() throws Exception { r = read("<RD,ID:the<<id:\"level\"\"Type\",CH>"); ft = r.read(); assertTrue(ft.get(0).equals("ID")); assertTrue(ft.get(1).equals("the&lt;id")); assertTrue(ft.get(2).equals("level&quot;Type")); assertTrue(ft.get(3).equals("CH")); assertTrue(ft.getOptionAfter("iD").equals("the&lt;id")); assertTrue(r.read() == null); }
public FolioToken read() throws IOException, InvalidMarkupException { tokensRead++; if (this.currentInnerReader != null) { FolioToken st = this.currentInnerReader.read(); if (st != null) return st; else { this.currentInnerReader.close(); this.currentInnerReader = null; } } TokenInfo ti = tracker.getTokenInfo(); Matcher m = getNextMatch(); if (m == null) return null; FolioToken ft = null; if (m.pattern() == rComment) { ft = new FolioToken(FolioToken.TokenType.Comment); ft.text = m.group(1); } else if (m.pattern() == rText) { ft = new FolioToken(FolioToken.TokenType.Text); ft.text = m.group(); Matcher msb = rSingleBracket.matcher(ft.text); } else if (m.pattern() == rTag) { ft = new FolioToken(FolioToken.TokenType.Tag); if (m.group(1) != null) { ft.isClosing(true); } ft.text = m.group(); ft.tagName = m.group(2); ft.tagOptions = m.group(3); } ft.info = ti; ft.info.length = m.end() - m.start(); ft.info.parentService = this.resolver; if (m.pattern() == rComment) ft.info.text = m.group(); else ft.info.text = ft.text; index = m.end(); if (ft.matches("CM")) { throw new InvalidMarkupException("Comment tags cannot specify options and must be present in pairs.", ft); } if (ft.type == FolioToken.TokenType.Tag) { if (ft.matches("DI|FI")) { if (this.resolver == null) { throw new InvalidMarkupException("File include requested, but no IncludeResolutionService was specified.", ft); } else { assert (ft.count() == 1); String path = ft.get(0); IIncludeResolutionService child = this.resolver.getChild(path); String hash = child.getHash(); if (this.parentDocumentPaths.contains(hash)) { throw new InvalidMarkupException("Circular reference: " + this.resolver.getDescription() + " contains a reference to parent document " + child.getDescription() + "... which is including " + this.resolver.getDescription()); } else { Reader r = child.getReader(); List<String> newPathChain = new ArrayList<String>(); newPathChain.addAll(this.parentDocumentPaths); newPathChain.add(hash); this.currentInnerReader = new FolioTokenReader(r, this.readSize, child, newPathChain); return this.read(); } } } } return ft; }
FolioTokenReader extends folioxml.core.TokenReaderBase { public FolioToken read() throws IOException, InvalidMarkupException { tokensRead++; if (this.currentInnerReader != null) { FolioToken st = this.currentInnerReader.read(); if (st != null) return st; else { this.currentInnerReader.close(); this.currentInnerReader = null; } } TokenInfo ti = tracker.getTokenInfo(); Matcher m = getNextMatch(); if (m == null) return null; FolioToken ft = null; if (m.pattern() == rComment) { ft = new FolioToken(FolioToken.TokenType.Comment); ft.text = m.group(1); } else if (m.pattern() == rText) { ft = new FolioToken(FolioToken.TokenType.Text); ft.text = m.group(); Matcher msb = rSingleBracket.matcher(ft.text); } else if (m.pattern() == rTag) { ft = new FolioToken(FolioToken.TokenType.Tag); if (m.group(1) != null) { ft.isClosing(true); } ft.text = m.group(); ft.tagName = m.group(2); ft.tagOptions = m.group(3); } ft.info = ti; ft.info.length = m.end() - m.start(); ft.info.parentService = this.resolver; if (m.pattern() == rComment) ft.info.text = m.group(); else ft.info.text = ft.text; index = m.end(); if (ft.matches("CM")) { throw new InvalidMarkupException("Comment tags cannot specify options and must be present in pairs.", ft); } if (ft.type == FolioToken.TokenType.Tag) { if (ft.matches("DI|FI")) { if (this.resolver == null) { throw new InvalidMarkupException("File include requested, but no IncludeResolutionService was specified.", ft); } else { assert (ft.count() == 1); String path = ft.get(0); IIncludeResolutionService child = this.resolver.getChild(path); String hash = child.getHash(); if (this.parentDocumentPaths.contains(hash)) { throw new InvalidMarkupException("Circular reference: " + this.resolver.getDescription() + " contains a reference to parent document " + child.getDescription() + "... which is including " + this.resolver.getDescription()); } else { Reader r = child.getReader(); List<String> newPathChain = new ArrayList<String>(); newPathChain.addAll(this.parentDocumentPaths); newPathChain.add(hash); this.currentInnerReader = new FolioTokenReader(r, this.readSize, child, newPathChain); return this.read(); } } } } return ft; } }
FolioTokenReader extends folioxml.core.TokenReaderBase { public FolioToken read() throws IOException, InvalidMarkupException { tokensRead++; if (this.currentInnerReader != null) { FolioToken st = this.currentInnerReader.read(); if (st != null) return st; else { this.currentInnerReader.close(); this.currentInnerReader = null; } } TokenInfo ti = tracker.getTokenInfo(); Matcher m = getNextMatch(); if (m == null) return null; FolioToken ft = null; if (m.pattern() == rComment) { ft = new FolioToken(FolioToken.TokenType.Comment); ft.text = m.group(1); } else if (m.pattern() == rText) { ft = new FolioToken(FolioToken.TokenType.Text); ft.text = m.group(); Matcher msb = rSingleBracket.matcher(ft.text); } else if (m.pattern() == rTag) { ft = new FolioToken(FolioToken.TokenType.Tag); if (m.group(1) != null) { ft.isClosing(true); } ft.text = m.group(); ft.tagName = m.group(2); ft.tagOptions = m.group(3); } ft.info = ti; ft.info.length = m.end() - m.start(); ft.info.parentService = this.resolver; if (m.pattern() == rComment) ft.info.text = m.group(); else ft.info.text = ft.text; index = m.end(); if (ft.matches("CM")) { throw new InvalidMarkupException("Comment tags cannot specify options and must be present in pairs.", ft); } if (ft.type == FolioToken.TokenType.Tag) { if (ft.matches("DI|FI")) { if (this.resolver == null) { throw new InvalidMarkupException("File include requested, but no IncludeResolutionService was specified.", ft); } else { assert (ft.count() == 1); String path = ft.get(0); IIncludeResolutionService child = this.resolver.getChild(path); String hash = child.getHash(); if (this.parentDocumentPaths.contains(hash)) { throw new InvalidMarkupException("Circular reference: " + this.resolver.getDescription() + " contains a reference to parent document " + child.getDescription() + "... which is including " + this.resolver.getDescription()); } else { Reader r = child.getReader(); List<String> newPathChain = new ArrayList<String>(); newPathChain.addAll(this.parentDocumentPaths); newPathChain.add(hash); this.currentInnerReader = new FolioTokenReader(r, this.readSize, child, newPathChain); return this.read(); } } } } return ft; } FolioTokenReader(Reader reader, int readBlockSize);  FolioTokenReader(File path);  FolioTokenReader(Reader reader, IIncludeResolutionService referenceResolver);  FolioTokenReader(Reader reader, int readBlockSize, IIncludeResolutionService referenceResolver);  FolioTokenReader(Reader reader, int readBlockSize, IIncludeResolutionService referenceResolver, List<String> parentDocumentPaths);  FolioTokenReader(Reader reader); }
FolioTokenReader extends folioxml.core.TokenReaderBase { public FolioToken read() throws IOException, InvalidMarkupException { tokensRead++; if (this.currentInnerReader != null) { FolioToken st = this.currentInnerReader.read(); if (st != null) return st; else { this.currentInnerReader.close(); this.currentInnerReader = null; } } TokenInfo ti = tracker.getTokenInfo(); Matcher m = getNextMatch(); if (m == null) return null; FolioToken ft = null; if (m.pattern() == rComment) { ft = new FolioToken(FolioToken.TokenType.Comment); ft.text = m.group(1); } else if (m.pattern() == rText) { ft = new FolioToken(FolioToken.TokenType.Text); ft.text = m.group(); Matcher msb = rSingleBracket.matcher(ft.text); } else if (m.pattern() == rTag) { ft = new FolioToken(FolioToken.TokenType.Tag); if (m.group(1) != null) { ft.isClosing(true); } ft.text = m.group(); ft.tagName = m.group(2); ft.tagOptions = m.group(3); } ft.info = ti; ft.info.length = m.end() - m.start(); ft.info.parentService = this.resolver; if (m.pattern() == rComment) ft.info.text = m.group(); else ft.info.text = ft.text; index = m.end(); if (ft.matches("CM")) { throw new InvalidMarkupException("Comment tags cannot specify options and must be present in pairs.", ft); } if (ft.type == FolioToken.TokenType.Tag) { if (ft.matches("DI|FI")) { if (this.resolver == null) { throw new InvalidMarkupException("File include requested, but no IncludeResolutionService was specified.", ft); } else { assert (ft.count() == 1); String path = ft.get(0); IIncludeResolutionService child = this.resolver.getChild(path); String hash = child.getHash(); if (this.parentDocumentPaths.contains(hash)) { throw new InvalidMarkupException("Circular reference: " + this.resolver.getDescription() + " contains a reference to parent document " + child.getDescription() + "... which is including " + this.resolver.getDescription()); } else { Reader r = child.getReader(); List<String> newPathChain = new ArrayList<String>(); newPathChain.addAll(this.parentDocumentPaths); newPathChain.add(hash); this.currentInnerReader = new FolioTokenReader(r, this.readSize, child, newPathChain); return this.read(); } } } } return ft; } FolioTokenReader(Reader reader, int readBlockSize);  FolioTokenReader(File path);  FolioTokenReader(Reader reader, IIncludeResolutionService referenceResolver);  FolioTokenReader(Reader reader, int readBlockSize, IIncludeResolutionService referenceResolver);  FolioTokenReader(Reader reader, int readBlockSize, IIncludeResolutionService referenceResolver, List<String> parentDocumentPaths);  FolioTokenReader(Reader reader); FolioToken read(); @Override boolean canRead(); @Override void close(); }
FolioTokenReader extends folioxml.core.TokenReaderBase { public FolioToken read() throws IOException, InvalidMarkupException { tokensRead++; if (this.currentInnerReader != null) { FolioToken st = this.currentInnerReader.read(); if (st != null) return st; else { this.currentInnerReader.close(); this.currentInnerReader = null; } } TokenInfo ti = tracker.getTokenInfo(); Matcher m = getNextMatch(); if (m == null) return null; FolioToken ft = null; if (m.pattern() == rComment) { ft = new FolioToken(FolioToken.TokenType.Comment); ft.text = m.group(1); } else if (m.pattern() == rText) { ft = new FolioToken(FolioToken.TokenType.Text); ft.text = m.group(); Matcher msb = rSingleBracket.matcher(ft.text); } else if (m.pattern() == rTag) { ft = new FolioToken(FolioToken.TokenType.Tag); if (m.group(1) != null) { ft.isClosing(true); } ft.text = m.group(); ft.tagName = m.group(2); ft.tagOptions = m.group(3); } ft.info = ti; ft.info.length = m.end() - m.start(); ft.info.parentService = this.resolver; if (m.pattern() == rComment) ft.info.text = m.group(); else ft.info.text = ft.text; index = m.end(); if (ft.matches("CM")) { throw new InvalidMarkupException("Comment tags cannot specify options and must be present in pairs.", ft); } if (ft.type == FolioToken.TokenType.Tag) { if (ft.matches("DI|FI")) { if (this.resolver == null) { throw new InvalidMarkupException("File include requested, but no IncludeResolutionService was specified.", ft); } else { assert (ft.count() == 1); String path = ft.get(0); IIncludeResolutionService child = this.resolver.getChild(path); String hash = child.getHash(); if (this.parentDocumentPaths.contains(hash)) { throw new InvalidMarkupException("Circular reference: " + this.resolver.getDescription() + " contains a reference to parent document " + child.getDescription() + "... which is including " + this.resolver.getDescription()); } else { Reader r = child.getReader(); List<String> newPathChain = new ArrayList<String>(); newPathChain.addAll(this.parentDocumentPaths); newPathChain.add(hash); this.currentInnerReader = new FolioTokenReader(r, this.readSize, child, newPathChain); return this.read(); } } } } return ft; } FolioTokenReader(Reader reader, int readBlockSize);  FolioTokenReader(File path);  FolioTokenReader(Reader reader, IIncludeResolutionService referenceResolver);  FolioTokenReader(Reader reader, int readBlockSize, IIncludeResolutionService referenceResolver);  FolioTokenReader(Reader reader, int readBlockSize, IIncludeResolutionService referenceResolver, List<String> parentDocumentPaths);  FolioTokenReader(Reader reader); FolioToken read(); @Override boolean canRead(); @Override void close(); static String CommentRegex; static String TextRegex; static String TagRegex; public long tokensRead; }