本文整理匯總了Java中nu.xom.Builder.build方法的典型用法代碼示例。如果您正苦於以下問題:Java Builder.build方法的具體用法?Java Builder.build怎麽用?Java Builder.build使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nu.xom.Builder
的用法示例。
在下文中一共展示了Builder.build方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTagList
import nu.xom.Builder; //導入方法依賴的package包/類
public static String getTagList(Project pjr){
try {
String filepath = FileStorage.JN_DOCPATH + ".projects";
Builder builder = new Builder();
Document projects = builder.build(new InputStreamReader(new FileInputStream(filepath)), "UTF-8");
String taglist="";
Elements prjs = projects.getRootElement().getChildElements("project");
for (int i = 0; i < prjs.size(); i++) {
String pid = ((Element) prjs.get(i)).getAttribute("id").getValue();
if (pid.equals(pjr.getID())){
Element tags=prjs.get(i).getFirstChildElement("tags");
Elements tagli=tags.getChildElements("tag");
if (tagli.size()<=0) return "no";
for (int j = 0; j < tagli.size(); j++) {
taglist+=tagli.get(j).getAttributeValue("name")+" - ";
}
break;
}
}
return taglist;
} catch (Exception e) {
Util.error(e);
return "no";
}
}
示例2: initialize
import nu.xom.Builder; //導入方法依賴的package包/類
@Override
public void initialize(final UimaContext context) throws ResourceInitializationException {
super.initialize(context);
dlinaDirectory = new File(dlinaDirectoryName);
if (!dlinaDirectory.isDirectory())
throw new ResourceInitializationException();
for (File f : dlinaDirectory.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".xml");
}
})) {
try {
Builder parser = new Builder();
Document doc = parser.build(new FileInputStream(f));
String sourceUrl = doc.getRootElement().getFirstChildElement("header", namespaceUri)
.getFirstChildElement("source", namespaceUri).getValue();
String sourceId = sourceUrl.substring(56).replace("/data", "");
fileIndex.put(sourceId, doc);
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
}
}
示例3: SettingsManager
import nu.xom.Builder; //導入方法依賴的package包/類
/**
* Constructs the class. Requires settings.xml to be present to run
*/
public SettingsManager() {
String currentDir = System.getProperty("user.dir");
String settingDir = currentDir + "/settings/";
File f = new File(settingDir + "settings.xml");
if (f.exists() && !f.isDirectory()) {
try {
Builder parser = new Builder();
Document doc = parser.build(f);
Element root = doc.getRootElement();
Element eUsername = root.getFirstChildElement("Username");
username = eUsername.getValue();
Element ePassword = root.getFirstChildElement("Password");
password = ePassword.getValue();
requiresAuth = true;
} catch (ParsingException|IOException e) {
e.printStackTrace();
}
}
else {
requiresAuth = false;
}
}
示例4: getDocument
import nu.xom.Builder; //導入方法依賴的package包/類
/**
* @param path the path of the requested document
* @return the document that lives under the given path in the ZIP fs.
* @throws IOException in case of any failure
*/
public Document getDocument(String path) throws IOException {
Builder builder = new Builder();
try {
byte[] documentData = content.get(path);
if (documentData == null) {
throw new IOException(
Messages.getString(
"ZipFs.invalidDocument",//$NON-NLS-1$
path));
}
return builder.build(new ByteArrayInputStream(content.get(path)));
} catch (ParsingException e) {
throw new IOException(e);
}
}
示例5: getInputDataTypes
import nu.xom.Builder; //導入方法依賴的package包/類
/**
* @return available input data types as offered by OxGarage
* @throws IOException in case of any failure
*/
Document getInputDataTypes() throws IOException {
String uri = baseURL + CONVERSION_OPERATION;
ClientResource client = new ClientResource(Context.getCurrent(), Method.GET, uri);
Representation result = client.get();
Builder builder = new Builder();
try {
Document inputDataTypes = builder.build(result.getStream());
return inputDataTypes;
}
catch (ParsingException e) {
throw new IOException(e);
}
}
示例6: test06
import nu.xom.Builder; //導入方法依賴的package包/類
/**
* Create Document Type
*/
@Test
public void test06() throws Exception{
Element greeting = new Element("greeting");
Document doc = new Document(greeting);
String temp = "<!DOCTYPE element [\n"
+ "<!ELEMENT greeting (#PCDATA)>\n"
+ "]>\n"
+ "<root />";
Builder builder = new Builder();
Document tempDoc = builder.build(temp, null);
DocType doctype = tempDoc.getDocType();
doctype.detach();
doc.setDocType(doctype);
System.out.println(doc.toXML());
}
示例7: load
import nu.xom.Builder; //導入方法依賴的package包/類
/**
* Load the specified xml and return a deep copy (storing the loaded file for next time)
*/
public Document load(String path) throws SAXException, IOException, ParsingException {
String fpath = basePath + path;
if (!loaded.containsKey(fpath)) {
XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
Builder parser = new Builder(xmlReader);
InputStream is = getClass().getClassLoader().getResourceAsStream(fpath);
if (is == null) {
is = new FileInputStream(fpath);
}
Document doc = parser.build(is);
loaded.put(fpath, doc);
}
return (Document) loaded.get(fpath).copy();
}
示例8: PlayerInit
import nu.xom.Builder; //導入方法依賴的package包/類
/** This is to init the player, but it doesn't directly init the object. Rather, it reads from the file, and returns a player object
* @param file the filename to read from
* @throws FileNotFoundException if the file cannot be found
* @throws FileFormatException when file is formatted wrongly
* @return the Player red from the file
*/
public static Player PlayerInit (String file) throws FileNotFoundException, FileFormatException{
File inputFile = new File (file);
MonsterQuest.game.player.Player player = new MonsterQuest.game.player.Player();
if (!inputFile.exists())
throw new FileNotFoundException("The file, " + file + " cannot be found");
try {
Builder inputFileBuilder = new Builder();
Document inputFileDoc = inputFileBuilder.build(inputFile);
Element root = inputFileDoc.getRootElement();
//Read name
Element nameElement = root.getFirstChildElement("name");
Text name = (Text) nameElement.getChild(0);
player.name = name.getValue();
Element gender = root.getFirstChildElement("gender");
Text genderText = (Text) gender.getChild(0);
if (genderText.getValue().equals("Boy")) {
//The player is a boy
player.setGender(GIRL);
}
else if (genderText.getValue().equals("Girl")) {
//The gender is a girl
player.setGender(GIRL);
}
else {
throw new FileFormatException("The text is corrupted, when the text should have been either \"Boy\" or \"Girl\", it was" + genderText.getValue());
}
} catch (ParsingException pe) {
//Throw a file format exception, because the file is formatted wrongly.
throw new FileFormatException("OOPS! File parsed wrongly!" + pe.getMessage());
} catch (IOException ioe ) {
}
return player;
}
示例9: getElement
import nu.xom.Builder; //導入方法依賴的package包/類
/**
* Creates a XOM element representing the root XML element in a reader.
*
* @param reader a reader mapping to an XML document
* @return a XOM element representing the root node in the document
*/
public Element getElement(Reader reader) throws IOException, InvalidDDMSException {
Util.requireValue("reader", reader);
try {
Builder builder = new Builder(getReader(), true);
Document doc = builder.build(reader);
return (doc.getRootElement());
}
catch (ParsingException e) {
throw new InvalidDDMSException(e);
}
}
示例10: readFlexBoneLinkBoundaries
import nu.xom.Builder; //導入方法依賴的package包/類
public static Vector3f[] readFlexBoneLinkBoundaries(int partID, LIFReader dbLifReader) throws IOException, ValidityException, ParsingException {
Builder builder = new Builder();
byte[] propertyFile = dbLifReader.readInternalFile(dbLifReader.getFileAt(DBFilePaths.primitivePropertiesDirectory + "/" + partID + ".xml"));
Document propertyDocument = builder.build(new ByteArrayInputStream(propertyFile));
Element rootNode = propertyDocument.getRootElement();
Element flexElement = rootNode.getFirstChildElement("Flex");
Elements boneElements = flexElement.getChildElements("Bone");
return readBoneBoundaries(boneElements);
}
示例11: readLXFMLFileContents
import nu.xom.Builder; //導入方法依賴的package包/類
private static Mesh readLXFMLFileContents(InputStream fileStream, LIFReader dbLifReader) throws IOException {
try {
Builder builder = new Builder();
Document doc = builder.build(fileStream);
Element rootElement = doc.getRootElement();
checkLIF(dbLifReader);
verifyFileVersion(rootElement);
return parseLXFMLFile(rootElement, dbLifReader);
} catch (Exception e) {
throw new IOException(e);
}
}
示例12: parse
import nu.xom.Builder; //導入方法依賴的package包/類
public static ModuleParseResult parse(final InputStream in) throws IOException, ParsingException {
Builder builder = new Builder(false);
final Document document;
try (InputStream in1 = in) {
document = builder.build(in1);
}
ModuleParseResult result = new ModuleParseResult(document);
final Element rootElement = document.getRootElement();
if (rootElement.getLocalName().equals("module-alias")) {
parseModuleAlias(rootElement, result);
} else if (rootElement.getLocalName().equals("module")) {
parseModule(rootElement, result);
}
return result;
}
示例13: getDetails
import nu.xom.Builder; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private String getDetails(String user) throws IOException {
String nonce = getNonce();
StringBuilder urlBuilder = new StringBuilder(confToolUrl);
urlBuilder.append("?page=remoteLogin"); //$NON-NLS-1$
urlBuilder.append("&nonce="); //$NON-NLS-1$
urlBuilder.append(nonce);
urlBuilder.append("&passhash="); //$NON-NLS-1$
urlBuilder.append(getPassHash(nonce));
urlBuilder.append("&user="); //$NON-NLS-1$
urlBuilder.append(user);
urlBuilder.append("&command=request"); //$NON-NLS-1$
ClientResource client =
new ClientResource(Context.getCurrent(), Method.GET, urlBuilder.toString());
Representation result = client.get();
try (InputStream resultStream = result.getStream()) {
Builder builder = new Builder();
Document resultDoc = builder.build(resultStream);
return resultDoc.toXML();
}
catch (Exception e) {
throw new IOException(e);
}
}
示例14: authenticate
import nu.xom.Builder; //導入方法依賴的package包/類
/**
* @param user a username
* @param pass a password
* @return the User
* @throws UserProvider.AuthenticationException in case of authentication failur
* @throws IOException in case of any other failure
*/
public User authenticate(String user, char[] pass)
throws IOException, UserProvider.AuthenticationException {
String nonce = getNonce();
// see: ConfTool REST interface specification
StringBuilder urlBuilder = new StringBuilder(confToolUrl);
urlBuilder.append("?page=remoteLogin"); //$NON-NLS-1$
urlBuilder.append("&nonce="); //$NON-NLS-1$
urlBuilder.append(nonce);
urlBuilder.append("&passhash="); //$NON-NLS-1$
urlBuilder.append(getPassHash(nonce));
urlBuilder.append("&user="); //$NON-NLS-1$
urlBuilder.append(URLEncoder.encode(user, "UTF-8"));
urlBuilder.append("&command=login"); //$NON-NLS-1$
urlBuilder.append("&password="); //$NON-NLS-1$
urlBuilder.append(URLEncoder.encode(String.valueOf(pass), "UTF-8"));
ClientResource client =
new ClientResource(Context.getCurrent(), Method.GET, urlBuilder.toString());
Representation result = client.get();
try (InputStream resultStream = result.getStream()) {
Builder builder = new Builder();
Document resultDoc = builder.build(resultStream);
if (getLoginResult(resultDoc) == LOGIN_SUCCESS) {
return getUser(resultDoc);
}
else {
throw new UserProvider.AuthenticationException(getMessage(resultDoc));
}
}
catch (Exception e) {
throw new IOException(e);
}
}
示例15: validateDocument
import nu.xom.Builder; //導入方法依賴的package包/類
/**
* Validates the given data against the DHConvalidator schema.
* @param bos the data to be validated
* @param progressListener a listner that can be notified about progress
* @throws IOException in case of any failure
*/
private void validateDocument(ByteArrayOutputStream bos, ConversionProgressListener progressListener) throws IOException {
if (PropertyKey.performSchemaValidation.isTrue()) {
try {
progressListener.setProgress(Messages.getString("Converter.progress5")); //$NON-NLS-1$
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
URL xsdResource =
Thread.currentThread().getContextClassLoader().getResource(
"/schema/dhconvalidator.xsd"); //$NON-NLS-1$
SchemaFactory schemaFactory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); //$NON-NLS-1$
factory.setSchema(schemaFactory.newSchema(xsdResource));
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
reader.setErrorHandler(new ValidateConversionErrorHandler());
Builder builder = new Builder(reader);
builder.build(new ByteArrayInputStream(bos.toByteArray()));
}
catch (ParsingException | ParserConfigurationException | SAXException e) {
throw new IOException(e);
}
}
}