Set<GraphNode> members() { throw new BrokenException( "cannot ask for components of a raw GraphNode" ); }
@Override Set<GraphNode> members() { throw new BrokenException( "cannot ask for components of a raw GraphNode" ); }
private void error(String msg) { JenaException e = new BrokenException("Internal error in Unparser: " + msg); this.prettyWriter.fatalError(e); throw e; // Just in case. }
public XSLT_RendererFactory( Resource root, MediaType mt ) { if (root == null) throw new BrokenException("XSLT_RendererFactory has not been given a root."); this.root = root; this.mt = mt; this.mode = Mode.decode(root, defaultMode); }
private String encodeNonAscii(String expanded) { StringBuilder result = new StringBuilder(); char[] hex = "0123456789ABCDEF".toCharArray(); try { byte[] bytes = expanded.getBytes("UTF-8"); for (int i = 0; i < bytes.length; i += 1) { int b = bytes[i] & 0xFF; if (b < 127) { result.append((char) b); } else { result.append("%").append(hex[b >> 4]).append(hex[b & 15]); } } } catch (UnsupportedEncodingException e) { throw new BrokenException(e); } return result.toString(); }
private String getLocalName(Resource r) { if (r.isAnon()) { logger.error("Internal error - giving up - Unparser.getLocalName"); throw new BrokenException("Internal error: getLocalName(bNode)"); } String uri = r.getURI(); int split = Util.splitNamespace(uri); return uri.substring(split); }
private String getNameSpace(Resource r) { if (r.isAnon()) { logger.error("Internal error - Unparser.getNameSpace; giving up"); throw new BrokenException("Internal error: getNameSpace(bNode)"); } String uri = r.getURI(); int split = Util.splitNamespace(uri); return uri.substring(0, split); }
private String cookUpAttribution( int type, String namespace, String local ) { String prefix = "j.cook.up"; switch (type) { case FASTATTR : case ATTR : return "xmlns:" + prefix + "=" + substitutedAttribute( namespace ) + " " + prefix + ":" + local; case START : return prefix + ":" + local + " xmlns:" + prefix+ "=" + substitutedAttribute( namespace ); default: case END : return prefix + ":" + local; case FAST : // logger.error("Unreachable code - reached."); throw new BrokenException( "cookup reached final FAST" ); } }
protected void grow() { Object [] oldContents = keys; TripleBunch [] oldValues = values; final int oldCapacity = capacity; growCapacityAndThreshold(); keys = newKeyArray( capacity ); values = new TripleBunch[capacity]; for (int i = 0; i < oldCapacity; i += 1) { Object key = oldContents[i]; if (key != null) { int j = findSlot( key ); if (j < 0) { throw new BrokenException( "oh dear, already have a slot for " + key + ", viz " + ~j ); } keys[j] = key; values[j] = oldValues[i]; } } }
throw new BrokenException( e );
+ namespace + ">. Fixing up with j.cook.up code.", new BrokenException( "unexpected QName URI " + namespace )); cookUp = true; } else if (prefix.length() == 0) {
/** For sorting values, every node should have a label. That's easy for literals and URI nodes, but bnode IDs are not stable, and for testing purposes if nothing else, we want the order of values to be the same every time. So for a bnode we give it the spelling of the lexical form of its literal label, if it has one. We try api:label then rdfs:label and otherwise fall back to the bnode ID and cross our fingers. */ private String objectTagOf( RDFNode r ) { if (r.isAnon()) { Statement labelling = r.asResource().getProperty( API.label ); if (labelling == null) labelling = r.asResource().getProperty( RDFS.label ); if (labelling != null) { RDFNode label = labelling.getObject(); if (label.isLiteral()) return label.asLiteral().getLexicalForm(); } return r.asNode().getBlankNodeLabel(); } // if (r.isURIResource()) { Resource r1 = (Resource) r; String shorter = nameMap.get( r1.getURI() ); return shorter == null ? r1.getURI() : shorter; } if (r.isLiteral()) { return ((Literal) r).getLexicalForm(); } throw new BrokenException("node " + r + " neither blank, literal, or URI."); }