public static final int parseContainerMembershipProperty(String p) throws ParseException{ if(!p.startsWith(NS+"_") || p.equals(NS+"_")){ throw new ParseException("Not a valid container membership property "+p); } else{ int v; try{ v = Integer.parseInt(p.substring((NS+"_").length())); } catch(Exception e){ throw new ParseException("Not a valid container membership property, not a valid numeric value."); } if(v<1){ throw new ParseException(v+ " not a valid container membership property value - must be 1 or greater."); } return v; } } }
public static Node[] parseNodes(final String line) throws ParseException { try { return parseNodesInternal(line); } catch (Exception e) { throw new ParseException(e); } }
public String[] parseContextualBNode() throws ParseException { String d = _data.substring(PREFIX.length()); String[] uri = d.toString().split("xx"); if (uri.length != 2) { throw new ParseException("Not a valid context encoded BNode " + _data); } uri[0] = unescapeForBNode(uri[0]); uri[1] = unescapeForBNode(uri[1]); return uri; }
/** * Constructor given Callback. * Interaction outside of iterator model but analogous to NxParser :(. */ @Deprecated // @@@@ need always context for relative URIs? public void parse(InputStream in, boolean strict, boolean skolemise, String baseURI, Callback c) throws ParseException, IOException { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(strict); try { SAXParser saxParser = factory.newSAXParser(); saxParser.parse(in, new RdfXmlParserBase(baseURI, c, skolemise)); } catch (Exception err) { throw new ParseException(err); // err.printStackTrace (); } }
/** * Constructor given Callback. * Interaction outside of iterator model but analagous to NxParser :(. * Produces quadruples using the provided context. * */ public void parse(InputStream in, boolean strict, boolean skolemise, String baseURI, Callback c, Resource con) throws ParseException, IOException { _con = con; SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(strict); try { SAXParser saxParser = factory.newSAXParser(); saxParser.parse(in, new RdfXmlParserBase(baseURI, c, skolemise, con)); } catch (Exception err) { throw new ParseException(err); // err.printStackTrace (); } }
public static String[] parseContextualBNode(BNode b) throws ParseException { String[] uri = b.toString().split("xx"); if (uri.length != 2) { throw new ParseException("Not a valid context encoded BNode " + b); } uri[0] = unescapeForBNode(uri[0]); uri[1] = unescapeForBNode(uri[1]); return uri; }
return new Node[0]; } else{ throw new ParseException("Could not find closing '.' bracket for line "+line); ++endIndex; if(endIndex==0) throw new ParseException("Could not find closing '>' bracket for resource starting at char "+startIndex+" while parsing line "+line); nx.add(new Resource(line.substring(startIndex, endIndex), true)); } else if (line.charAt(startIndex) == '_') { throw new ParseException("Exception at position " + startIndex+ " while parsing: '" + line +"'"); if (endIndex >= line.length() || line.charAt(endIndex) != ' ') { throw new ParseException("Exception at position " + startIndex + " while parsing: '" + line + "'"); throw new ParseException("Exception at position " + endIndex+ " while parsing: '" + line +"'"); throw new ParseException("Exception at position " + endIndex+ " while parsing: '" + line +"'");
/** * Default constructor. Creates a BlockingCallBack instance, whose buffer is filled * by a parser thread and consumed by this instance using the iterator model. */ public Iterator<Node[]> parse(InputStream in, boolean strict, boolean skolemise, String baseURI, int buffer) throws ParseException, IOException { // SAXParserFactory factory = SAXParserFactory.newInstance(); // factory.setNamespaceAware(true); // factory.setValidating(strict); try { // SAXParser saxParser = factory.newSAXParser(); _q = new ArrayBlockingQueue<Node[]>(buffer); CallbackBlockingQueue bcb = new CallbackBlockingQueue(_q); _pt = new ParserThread(_parser, in, new RdfXmlParserBase(baseURI, bcb, skolemise),_q); _pt.start(); } catch (Exception err) { throw new ParseException(err); // err.printStackTrace (); } return this; }