@Override public int read(char[] cbuf, int off, int len) throws IOException { ensureOpen(); if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (next >= length) { return -1; } int n = Math.min(length - next, len); str.getChars(next, next + n, cbuf, off); next += n; return n; }
reader.set(xml); try { return expression.evaluate(builder.parse(inputSource), qname);
reader.set(xml); try { return expression.evaluate(builder.parse(inputSource), qname);
public Object eval(String xml, String path, QName qname) throws XPathExpressionException { if (xml == null || path == null || qname == null) { return null; } if (xml.length() == 0 || path.length() == 0) { return null; } if (!path.equals(oldPath)) { try { expression = xpath.compile(path); } catch (XPathExpressionException e) { throw new RuntimeException("Invalid XPath '" + path + "'" + e.getMessage(), e); } oldPath = path; } if (expression == null) { return null; } reader.set(xml); try { return expression.evaluate(inputSource, qname); } catch (XPathExpressionException e) { throw new RuntimeException("Invalid XML document: " + e.getMessage() + "\n" + xml, e); } }
@Override public int read(char[] cbuf, int off, int len) throws IOException { ensureOpen(); if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (next >= length) { return -1; } int n = Math.min(length - next, len); str.getChars(next, next + n, cbuf, off); next += n; return n; }
@Override public int read(char[] cbuf, int off, int len) throws IOException { ensureOpen(); if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } if (next >= length) { return -1; } int n = Math.min(length - next, len); str.getChars(next, next + n, cbuf, off); next += n; return n; }
@Override public void mark(int readAheadLimit) throws IOException { if (readAheadLimit < 0) { throw new IllegalArgumentException("Read-ahead limit < 0"); } ensureOpen(); mark = next; }
@Override public long skip(long ns) throws IOException { ensureOpen(); if (next >= length) { return 0; } // Bound skip by beginning and end of the source long n = Math.min(length - next, ns); n = Math.max(-next, n); next += n; return n; }
@Override public boolean ready() throws IOException { ensureOpen(); return true; }
@Override public long skip(long ns) throws IOException { ensureOpen(); if (next >= length) { return 0; } // Bound skip by beginning and end of the source long n = Math.min(length - next, ns); n = Math.max(-next, n); next += n; return n; }
@Override public int read() throws IOException { ensureOpen(); if (next >= length) { return -1; } return str.charAt(next++); }
@Override public void mark(int readAheadLimit) throws IOException { if (readAheadLimit < 0) { throw new IllegalArgumentException("Read-ahead limit < 0"); } ensureOpen(); mark = next; }
@Override public void reset() throws IOException { ensureOpen(); next = mark; }
@Override public long skip(long ns) throws IOException { ensureOpen(); if (next >= length) { return 0; } // Bound skip by beginning and end of the source long n = Math.min(length - next, ns); n = Math.max(-next, n); next += n; return n; }
@Override public boolean ready() throws IOException { ensureOpen(); return true; }
@Override public int read() throws IOException { ensureOpen(); if (next >= length) { return -1; } return str.charAt(next++); }
@Override public void mark(int readAheadLimit) throws IOException { if (readAheadLimit < 0) { throw new IllegalArgumentException("Read-ahead limit < 0"); } ensureOpen(); mark = next; }
@Override public void reset() throws IOException { ensureOpen(); next = mark; }
@Override public boolean ready() throws IOException { ensureOpen(); return true; }
@Override public void reset() throws IOException { ensureOpen(); next = mark; }