public static String getCharset(String contentType, String defaultCharset) { String charset = HttpUtils.getCharset(contentType); if (charset == null) { return defaultCharset; } else { return charset; } }
public static String getCharset(String contentType, String defaultCharset) { String charset = HttpUtils.getCharset(contentType); if (charset == null) { return defaultCharset; } else { return charset; } }
private String parseCharset(String contentType) { String charset = HttpUtils.getCharset(contentType); if (charset != null) { return charset.toLowerCase(); } return null; } }
private String parseCharset(String contentType) { String charset = HttpUtils.getCharset(contentType); if (charset != null) { return charset.toLowerCase(); } return null; } }
public void load(URI id, String media, InputStream content, long len) throws IOException { String cs = HttpUtils.getCharset(media); if (cs == null) { cs = Charset.defaultCharset().name(); } InputStreamReader reader = new InputStreamReader(content, cs); JSONTokener jt = new JSONTokener(reader); Processor processor = runtime.getProcessor(); String flavor = runtime.jsonFlavor(); documents.add(JSONtoXML.convert(processor, jt, flavor)); } });
public void load(URI id, String media, InputStream content, long len) throws IOException { String cs = HttpUtils.getCharset(media); if (cs == null) { cs = Charset.defaultCharset().name(); } InputStreamReader reader = new InputStreamReader(content, cs); JSONTokener jt = new JSONTokener(reader); Processor processor = runtime.getProcessor(); String flavor = runtime.jsonFlavor(); documents.add(JSONtoXML.convert(processor, jt, flavor)); } });
String readText(final XdmNode node, final XPointer xpointer, String media, InputStream content, long len) throws IOException { String charset = HttpUtils.getCharset(media); if (charset == null && node.getAttributeValue(_encoding) != null) { charset = node.getAttributeValue(_encoding); } if (charset == null) { charset = "utf-8"; } // Get the response BufferedReader rd = new BufferedReader(new InputStreamReader(content, charset)); String data = ""; if (xpointer != null) { data = xpointer.selectText(rd, (int) len); } else { String line; while ((line = rd.readLine()) != null) { data += line + "\n"; } } rd.close(); if (trimText) { return data.trim(); } else { return data; } }
String readText(final XdmNode node, final XPointer xpointer, String media, InputStream content, long len) throws IOException { String charset = HttpUtils.getCharset(media); if (charset == null && node.getAttributeValue(_encoding) != null) { charset = node.getAttributeValue(_encoding); } if (charset == null) { charset = "utf-8"; } // Get the response BufferedReader rd = new BufferedReader(new InputStreamReader(content, charset)); String data = ""; if (xpointer != null) { data = xpointer.selectText(rd, (int) len); } else { String line; while ((line = rd.readLine()) != null) { data += line + "\n"; } } rd.close(); if (trimText) { return data.trim(); } else { return data; } }
String bodyDisposition = body.getAttributeValue(_disposition); String bodyCharset = HttpUtils.getCharset(bodyContentType);
String bodyDisposition = body.getAttributeValue(_disposition); String bodyCharset = HttpUtils.getCharset(bodyContentType);
public void load(URI id, String contentType, InputStream bodyStream, long len) throws IOException { // Get the default charset from the file.encoding system property. // Fall back to UTF-8 if that's not set. String defCharset = System.getProperty("file.encoding","UTF-8"); String charset = HttpUtils.getCharset(contentType, defCharset); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(id); try { if (xmlContentType(contentType)) { readBodyContentPart(tree, bodyStream, contentType, charset); } else { tree.addStartElement(XProcConstants.c_body); tree.addAttribute(_content_type, contentType); if (!xmlContentType(contentType) && !textContentType(contentType)) { tree.addAttribute(_encoding, "base64"); } tree.startContent(); readBodyContentPart(tree, bodyStream, contentType, charset); tree.addEndElement(); } tree.endDocument(); XdmNode doc = tree.getResult(); result.write(doc); } catch (SaxonApiException sae) { throw new XProcException(sae); } } });
public void load(URI id, String contentType, InputStream bodyStream, long len) throws IOException { // Get the default charset from the file.encoding system property. // Fall back to UTF-8 if that's not set. String defCharset = System.getProperty("file.encoding","UTF-8"); String charset = HttpUtils.getCharset(contentType, defCharset); TreeWriter tree = new TreeWriter(runtime); tree.startDocument(id); try { if (xmlContentType(contentType)) { readBodyContentPart(tree, bodyStream, contentType, charset); } else { tree.addStartElement(XProcConstants.c_body); tree.addAttribute(_content_type, contentType); if (!xmlContentType(contentType) && !textContentType(contentType)) { tree.addAttribute(_encoding, "base64"); } tree.startContent(); readBodyContentPart(tree, bodyStream, contentType, charset); tree.addEndElement(); } tree.endDocument(); XdmNode doc = tree.getResult(); result.write(doc); } catch (SaxonApiException sae) { throw new XProcException(sae); } } });
String defCharset = HttpUtils.getCharset(contentType); contentType = HttpUtils.baseContentType(contentType);
String defCharset = HttpUtils.getCharset(contentType); contentType = HttpUtils.baseContentType(contentType);