@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); } }
@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); } }
builder.withValue(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME, lastname); builder.withValue(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, firstname); ops.add(builder.build()); builder.withSelection(ContactsContract.Data.CONTACT_ID + "=?" + " AND " + ContactsContract.Data.MIMETYPE + "=?"+ " AND " + ContactsContract.CommonDataKinds.Organization.TYPE + "=?", new String[]{String.valueOf(id), ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE, String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_HOME)}); builder.withValue(ContactsContract.CommonDataKinds.Phone.NUMBER, number); ops.add(builder.build()); builder.withSelection(ContactsContract.Data.CONTACT_ID + "=?" + " AND " + ContactsContract.Data.MIMETYPE + "=?", new String[]{String.valueOf(id), ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE}); builder.withValue(ContactsContract.CommonDataKinds.Photo.PHOTO, image.toByteArray()); ops.add(builder.build());
Builder boundsBuilder = new LatLngBounds.Builder(); boundsBuilder.include(currentLocationLatLng); boundsBuilder.include(targetLocationLatLng); // pan to see all markers on map: LatLngBounds bounds = boundsBuilder.build(); googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 3));
@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); } } }
@Override public void onClick(final View v) { Location location = this.mGoogleMap.getMyLocation(); if (location != null) { LatLng target = new LatLng(location.getLatitude(), location.getLongitude()); CameraPosition position = this.mGoogleMap.getCameraPosition(); Builder builder = new CameraPosition.Builder(); builder.zoom(15); builder.target(target); this.mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(builder.build())); } }
public Object getDocument(String s) throws FunctionCallException { try { return new Builder(new NodeFactory()).build(s); } catch (Exception pe) { throw new FunctionCallException(pe); } }
public HierarchicalStreamReader createReader(URL in) { try { final Document document = createBuilder().build(in.toExternalForm()); return new XomReader(document, getNameCoder()); } catch (ValidityException e) { throw new StreamException(e); } catch (ParsingException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
Builder parser = new Builder(); StringReader in = new StringReader(xml); docElem = parser.build(in).getRootElement(); } catch (ParsingException | IOException e) { throw new RuntimeException(String.format("error:\n%s\ninput:\n%s", e, xml));
public HierarchicalStreamReader createReader(Reader text) { try { final Document document = createBuilder().build(text); return new XomReader(document, getNameCoder()); } catch (ValidityException e) { throw new StreamException(e); } catch (ParsingException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
public HierarchicalStreamReader createReader(File in) { try { final Document document = createBuilder().build(in); return new XomReader(document, getNameCoder()); } catch (ValidityException e) { throw new StreamException(e); } catch (ParsingException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
public HierarchicalStreamReader createReader(InputStream in) { try { final Document document = createBuilder().build(in); return new XomReader(document, getNameCoder()); } catch (ValidityException e) { throw new StreamException(e); } catch (ParsingException e) { throw new StreamException(e); } catch (IOException e) { throw new StreamException(e); } }
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(lRosterContentCount); Builder cpo = ContentProviderOperation.newUpdate(ProviderConstants.CONTENT_URI); cpo.withValues(Entries); cpo.withSelection(SQLTables.ID + "=?", selection); ops.add(cpo.build());
OkHttpClient httpClient = new OkHttpClient.Builder() .addInterceptor(new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Builder ongoing = chain.request().newBuilder(); ongoing.addHeader("Accept", "application/json;versions=1"); if (isUserLoggedIn()) { ongoing.addHeader("Authorization", getToken()); } return chain.proceed(ongoing.build()); } }) .build(); Retrofit retrofit = new Retrofit.Builder() // ... extra config .client(httpClient) .build();
public static void main(String[] args) throws IOException { Path file = Paths.get("c:/touch.txt"); AclFileAttributeView aclAttr = Files.getFileAttributeView(file, AclFileAttributeView.class); System.out.println(aclAttr.getOwner()); for(AclEntry aclEntry : aclAttr.getAcl()){ System.out.println(aclEntry); } System.out.println(); UserPrincipalLookupService upls = file.getFileSystem().getUserPrincipalLookupService(); UserPrincipal user = upls.lookupPrincipalByName(System.getProperty("user.name")); AclEntry.Builder builder = AclEntry.newBuilder(); builder.setPermissions( EnumSet.of(AclEntryPermission.READ_DATA, AclEntryPermission.EXECUTE, AclEntryPermission.READ_ACL, AclEntryPermission.READ_ATTRIBUTES, AclEntryPermission.READ_NAMED_ATTRS, AclEntryPermission.WRITE_ACL, AclEntryPermission.DELETE )); builder.setPrincipal(user); builder.setType(AclEntryType.ALLOW); aclAttr.setAcl(Collections.singletonList(builder.build())); }
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());
private LatLng getPolygonCenterPoint(ArrayList<LatLng> polygonPointsList){ LatLng centerLatLng = null; Builder builder = new LatLngBounds.Builder(); for(int i = 0 ; i < polygonPointsList.size() ; i++) { builder.include(polygonPointsList.get(i)); } LatLngBounds bounds = builder.build(); centerLatLng = bounds.getCenter(); return centerLatLng; }
@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