/** String to ByteBuffer as UTF-8 bytes */ public static ByteBuffer stringToByteBuffer(String str) { byte[] b = StrUtils.asUTF8bytes(str) ; return ByteBuffer.wrap(b) ; }
public static void resetLogging(String config) { Properties p = new Properties() ; InputStream in = new ByteArrayInputStream(StrUtils.asUTF8bytes(config)) ; try { p.load(in) ; } catch (IOException ex) {} PropertyConfigurator.configure(p) ; System.setProperty("log4j.configuration", "set") ; }
/** * Reset logging (log4j). */ public static void resetLogging(String config) { Properties p = new Properties() ; InputStream in = new ByteArrayInputStream(StrUtils.asUTF8bytes(config)) ; try { p.load(in) ; } catch (IOException ex) {} PropertyConfigurator.configure(p) ; System.setProperty("log4j.configuration", "set") ; }
/** Write the process id to the file. */ private void writeProcessId(int pid) throws IOException { byte b[] = StrUtils.asUTF8bytes(Integer.toString(pid)+"\n"); fileChannel.truncate(0); int len = fileChannel.write(ByteBuffer.wrap(b)); fileChannel.position(0); } }
/** * Reset logging (log4j). */ public static void resetLogging(String config) { Properties p = new Properties() ; InputStream in = new ByteArrayInputStream(StrUtils.asUTF8bytes(config)) ; try { p.load(in) ; } catch (IOException ex) {} PropertyConfigurator.configure(p) ; System.setProperty("log4j.configuration", "set") ; }
/** Write the process id to the file. */ private void writeProcessId(int pid) throws IOException { byte b[] = StrUtils.asUTF8bytes(Integer.toString(pid)+"\n"); fileChannel.truncate(0); int len = fileChannel.write(ByteBuffer.wrap(b)); fileChannel.position(0); } }
public static Tokenizer makeTokenizerASCII(String string) { byte b[] = StrUtils.asUTF8bytes(string) ; ByteArrayInputStream in = new ByteArrayInputStream(b) ; return makeTokenizerASCII(in) ; }
static protected Tokenizer tokenizer(String string) { // UTF-8 byte b[] = StrUtils.asUTF8bytes(string); ByteArrayInputStream in = new ByteArrayInputStream(b); Tokenizer tokenizer = TokenizerFactory.makeTokenizerUTF8(in); return tokenizer; }
static void write(ObjectFile file, String str) { byte b[] = StrUtils.asUTF8bytes(str) ; ByteBuffer bb = ByteBuffer.wrap(b) ; file.write(bb) ; }
static void write(ObjectFile file, String str) { byte b[] = StrUtils.asUTF8bytes(str) ; ByteBuffer bb = ByteBuffer.wrap(b) ; file.write(bb) ; }
static void write(ObjectFile file, String str) { byte b[] = StrUtils.asUTF8bytes(str) ; ByteBuffer bb = ByteBuffer.wrap(b) ; file.write(bb) ; }
static void write(ObjectFile file, String str) { byte b[] = StrUtils.asUTF8bytes(str) ; ByteBuffer bb = ByteBuffer.wrap(b) ; file.write(bb) ; }
static protected Tokenizer tokenizer(CharSpace charSpace, String string) { byte b[] = StrUtils.asUTF8bytes(string); ByteArrayInputStream in = new ByteArrayInputStream(b); Tokenizer tokenizer = charSpace == CharSpace.ASCII ? TokenizerFactory.makeTokenizerASCII(in) : TokenizerFactory.makeTokenizerUTF8(in); return tokenizer; }
private void parseTSVAsBoolean(String x, boolean expected) { byte[] b = StrUtils.asUTF8bytes(x); ByteArrayInputStream in = new ByteArrayInputStream(b); boolean actual = TSVInput.booleanFromTSV(in); Assert.assertEquals(expected, actual); } }
private void parseJSON(String input) { byte[] b = StrUtils.asUTF8bytes(input); ByteArrayInputStream in = new ByteArrayInputStream(b); ResultSet rs = ResultSetFactory.fromJSON(in); while (rs.hasNext()) { rs.nextBinding(); } }
private void parseTSV(String x) { byte[] b = StrUtils.asUTF8bytes(x); ByteArrayInputStream in = new ByteArrayInputStream(b); ResultSet rs2 = ResultSetFactory.fromTSV(in); while (rs2.hasNext()) { rs2.nextBinding(); } }
private void parseCSV(String x) { byte[] b = StrUtils.asUTF8bytes(x); ByteArrayInputStream in = new ByteArrayInputStream(b); ResultSet rs2 = CSVInput.fromCSV(in); while (rs2.hasNext()) { rs2.nextBinding(); } }
@Test(expected=IllegalArgumentException.class) public void rdfjson_invalid_tokenizer() { byte b[] = StrUtils.asUTF8bytes("") ; ByteArrayInputStream in = new ByteArrayInputStream(b); Tokenizer tokenizer = TokenizerFactory.makeTokenizerUTF8(in) ; StreamRDFCounting sink = StreamRDFLib.count() ; LangRDFJSON parser = RiotParsers.createParserRdfJson(tokenizer, sink, RiotLib.dftProfile()) ; }
@Test public void test_RS_1_str() { ResultSetRewindable rs1 = new ResultSetMem() ; String x = ResultSetFormatter.asXMLString(rs1) ; rs1.reset() ; InputStream in = new ByteArrayInputStream(StrUtils.asUTF8bytes(x)); ResultSet rs2 = ResultSetFactory.fromXML(in) ; assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ; }
@Test public void test_RS_2_str() { ResultSetRewindable rs1 = makeRewindable("x", org.apache.jena.graph.NodeFactory.createURI("tag:local")) ; String x = ResultSetFormatter.asXMLString(rs1) ; rs1.reset() ; InputStream in = new ByteArrayInputStream(StrUtils.asUTF8bytes(x)); ResultSet rs2 = ResultSetFactory.fromXML(in) ; assertTrue(ResultSetCompare.equalsByTerm(rs1, rs2)) ; }