本文整理了Java中nu.xom.Builder
类的一些代码示例,展示了Builder
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Builder
类的具体详情如下:
包路径:nu.xom.Builder
类名称:Builder
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
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();
} catch (ParsingException | IOException e) {
throw new RuntimeException(String.format("error:\n%s\ninput:\n%s", e, xml));
代码示例来源:origin: stackoverflow.com
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));
代码示例来源:origin: AxonFramework/AxonFramework
@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);
}
}
}
代码示例来源:origin: stackoverflow.com
@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()));
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* 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();
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
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);
}
}
代码示例来源:origin: se.vgregion.pubsubhubbub/pubsubhubbub-hub-composite-pubsub
public static Element stringToXml(String xml) {
if(xml == null) return null;
try {
Document doc = PARSER.build(new StringReader(xml));
Element elm = doc.getRootElement();
return (Element) elm.copy();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: stackoverflow.com
Builder parse = new Builder();
Document xml = parse.build("/var/www/JAVA/toForum.xml");
System.out.println(xml.query("//location[@id=83]/*").get(0).getParent().toXML());
代码示例来源:origin: stackoverflow.com
builder.withSelection(ContactsContract.Data.CONTACT_ID + "=?" + " AND " + ContactsContract.Data.MIMETYPE + "=?", new String[]{String.valueOf(id), ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE});
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());
代码示例来源:origin: stackoverflow.com
String myxml = "<resp><status>good</status><msg>hi</msg></resp>";
Document document = new Builder().build(myxml, "test.xml");
Nodes nodes = document.query("/resp/status");
System.out.println(nodes.get(0).getValue());
代码示例来源:origin: stackoverflow.com
XMLReader tagsoup = XMLReaderFactory.createXMLReader("org.ccil.cowan.tagsoup.Parser");
Builder bob = new Builder(tagsoup);
Document html = bob.build("http://www.yahoo.com");
Nodes images = html.query("//img");
for (int index = 0; index < images.size(); index++) {
Element image = (Element) images.get(index);
String src = image.getAttribute("src").getValue();
// do something with it...
}
代码示例来源:origin: stackoverflow.com
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());
代码示例来源:origin: stackoverflow.com
Builder builder = new Builder(this);
builder.setTitle("foo");
代码示例来源:origin: stackoverflow.com
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()));
}
代码示例来源:origin: stackoverflow.com
Builder builder1 = new Builder();
builder1.scheme("mailto");
builder1.opaquePart(emailAddress);
Builder builder2 = new Builder();
builder2.appendQueryParameter("subject", subject);
builder2.appendQueryParameter("body", body);
Uri uri = Uri.parse(builder1.toString() + builder2.toString());
代码示例来源:origin: stackoverflow.com
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();
代码示例来源:origin: stackoverflow.com
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
代码示例来源:origin: stackoverflow.com
Gtk.init(args); //Init library
Builder b = new Builder(); //Create builder
b.addFromFile("filename.glade"); //Load layout from file
Window w = (Window) b.getObject("myWindowName"); //Retrieve an object
w.showAll(); //Show window
Gtk.main();
代码示例来源:origin: stackoverflow.com
Builder b = factory.createObjectBuilder();
for(Friendship f: listFriends){
b.add("From: "+f.getUser_from().getLogin()+", To: "+ f.getUser_to().getLogin());
}
value = b.build();
代码示例来源:origin: stackoverflow.com
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public static Notification build(final Builder builder) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
return builder.build();
} else {
return builder.getNotification();
}
}
内容来源于网络,如有侵权,请联系作者删除!