/** * Create the Builder instance. * * A XOM builder is a wrapper around a {@link org.xml.sax.XMLReader} * instance which is not thread-safe by definition. Therefore each reader * should use its own builder instance to avoid concurrency problems. * * Overload this method to configure the generated builder instances e.g. * to activate validation. * * @return the new builder * @since 1.4.9 */ protected Builder createBuilder() { final Builder builder = getBuilder(); return builder != null ? builder : new Builder(); }
@Override public void init() throws ServletException { pipeline = new StanfordCoreNLP(); String xslPath = getServletContext(). getRealPath("/WEB-INF/data/CoreNLP-to-HTML.xsl"); try { Builder builder = new Builder(); Document stylesheet = builder.build(new File(xslPath)); corenlpTransformer = new XSLTransform(stylesheet); } catch (Exception e) { throw new ServletException(e); } }
Builder builder = new Builder(this); final EditText input = new EditText(this); builder .setTitle(R.string.dialog_title_addsubject) .setMessage(R.string.dialog_addsubject) .setView(input) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String value = input.getText().toString(); if (input.getText().toString().trim().length() == 0) { Toast.makeText(Main.this, R.string.input_empty, Toast.LENGTH_SHORT).show(); } else { db.insertSubject(value); getData(); } InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(input.getWindowToken(), 0); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(input.getWindowToken(), 0); } }); builder.show(); input.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
@Override public Document convert(InputStream original) { try { return new Builder().build(new InputStreamReader(original)); } catch (ParsingException | IOException e) { throw new CannotConvertBetweenTypesException("Cannot convert from InputStream to XOM Document.", e); } } }
protected Document getDocumentFromFile(final File f) throws IOException, XMLException { try { Builder parser = new Builder(); Document doc = parser.build(f); return doc; } catch (ParsingException | IOException ex) { throw new XMLException(ex.getMessage(), ex); } }
@Deprecated public static String indentXML(final String in) throws XMLException, IOException { try { Builder parser = new Builder(); Document doc = parser.build(in, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Serializer serializer = new Serializer(baos); serializer.setIndent(4); serializer.setMaxLength(69); serializer.write(doc); return new String(baos.toByteArray()); } catch (ParsingException ex) { // LOG.log(Level.SEVERE, null, ex); throw new XMLException("XML indentation failed.", ex); } } }
public Object getDocument(String s) throws FunctionCallException { try { return new Builder(new NodeFactory()).build(s); } catch (Exception pe) { throw new FunctionCallException(pe); } }
private static Annotation toAnnotation(String xml) throws IOException { Element docElem; try { Builder parser = new Builder(); StringReader in = new StringReader(xml); docElem = parser.build(in).getRootElement();
import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; ... XMLReader xmlreader = XMLReaderFactory.createXMLReader(); xmlreader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); Builder builder = new Builder(xmlreader);
Builder builder = new Builder(this); builder.setTitle("foo");
import nu.xom.*; import java.io.*; [...] public static String format(String xml) throws ParsingException, IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); Serializer serializer = new Serializer(out); serializer.setIndent(4); // or whatever you like serializer.write(new Builder().build(xml, "")); return out.toString("UTF-8"); }
import nu.xom.Builder; import nu.xom.Document; import java.io.File; [...] File file = new File("some/path"); Document document = new Builder().build(file);
//measured as 223 pixels on Nexus 5, which has xxhdpi, so divide by 3 final float oneDegreeInPixels = convertDpToPixels( 223.0f / 3.0f); final float mapViewCenter = mapViewHeight / 2.0f; final float bottomViewHeight = ...; final float posToFocusInPixelsFromTop = (mapViewHeight - bottomViewHeight) / 2.0f ;// can optionally add the height of the view on the top area final float deltaLatDegreesToMove = (mapViewCenter - posToFocusInPixelsFromTop) / oneDegreeInPixels; LatLng posToFocusOn = new LatLng(latitude - deltaLatDegreesToMove, longitude); final CameraUpdate cameraPosition = CameraUpdateFactory.newCameraPosition(new Builder().target(posToFocusOn).zoom(neededZoom).build());
/** * Create the Builder instance. A XOM builder is a wrapper around a {@link org.xml.sax.XMLReader} instance which is * not thread-safe by definition. Therefore each reader should use its own builder instance to avoid concurrency * problems. Overload this method to configure the generated builder instances e.g. to activate validation. * * @return the new builder * @since 1.4.9 */ protected Builder createBuilder() { final Builder builder = getBuilder(); return builder != null ? builder : new Builder(); }
import nu.xom.*; [...] Builder builder = new Builder(); Document alertDoc = builder.build(new File("src/xomtest", "alertset.xml")); Document weatherDoc = builder.build(new File("src/xomtest", "weatherset.xml")); Document mainDoc = builder.build("<DataSet><blank/><blank/></DataSet>", ""); Element root = mainDoc.getRootElement(); root.replaceChild( root.getFirstChildElement("blank"), alertDoc.getRootElement().copy()); root.replaceChild( root.getFirstChildElement("blank"), weatherDoc.getRootElement().copy());
Builder foo = new Builder(1, 2); // The "return" value of a ctor is the reference, foo foo.sodium(10); // Returns foo, but we ignore it foo.calories(42); // Returns foo, but we ignore it (foo.sodium(10)).calories(42); ^^^^^^^^^^^^^^^^ foo, with the side effect of setting the sodium value
@Override public void source(String systemId) throws Exception { try { Builder builder = new Builder(); Document document = builder.build(systemId); element = document.getRootElement(); } catch (ParsingException ex) { throw new XomParsingException(ex); } } }
@Override public void streamSource(Reader reader) throws IOException { try { Builder builder = new Builder(); Document document = builder.build(reader); element = document.getRootElement(); } catch (ParsingException ex) { throw new XomParsingException(ex); } }
@Override public void streamSource(InputStream inputStream) throws IOException { try { Builder builder = new Builder(); Document document = builder.build(inputStream); element = document.getRootElement(); } catch (ParsingException ex) { throw new XomParsingException(ex); } }
public People(String fileName) throws Exception { Document doc = new Builder().build(new File(fileName)); Elements elements = doc.getRootElement().getChildElements(); for(int i = 0; i < elements.size(); i++) add(new APerson(elements.get(i))); } public static void