當前位置: 首頁>>代碼示例>>Java>>正文


Java Document類代碼示例

本文整理匯總了Java中nu.xom.Document的典型用法代碼示例。如果您正苦於以下問題:Java Document類的具體用法?Java Document怎麽用?Java Document使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Document類屬於nu.xom包,在下文中一共展示了Document類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: openPSP

import nu.xom.Document; //導入依賴的package包/類
public javax.swing.text.Document openPSP(PSP psp) {

        HTMLDocument doc = (HTMLDocument) editorKit.createDefaultDocument();
        if (psp == null)
            return doc;
        String filename = getPSPPath(psp);
        try {
            /*DEBUG*/

//            Util.debug("Open note: " + filename);
//        	Util.debug("Note Title: " + note.getTitle());
        	doc.setBase(new URL(getPSPURL(psp)));
        	editorKit.read(
                new InputStreamReader(new FileInputStream(filename), "UTF-8"),
                doc,
                0);
        }
        catch (Exception ex) {
            //ex.printStackTrace();
            // Do nothing - we've got a new empty document!
        }
        
        return doc;
    }
 
開發者ID:ser316asu,項目名稱:Dahlem_SER316,代碼行數:25,代碼來源:FileStorage.java

示例2: MusicXmlRenderer

import nu.xom.Document; //導入依賴的package包/類
public MusicXmlRenderer(DurationHandler durationHandler, KeySigHandler keySigHandler) {
    this.durationHandler = durationHandler;
    margin = durationHandler.shortestNoteLengthInMillis();
    this.keySigHandler = keySigHandler;

    elRoot = new Element("score-partwise");
    Element elID = new Element("identification");
    Element elCreator = new Element("creator");
    elCreator.addAttribute(new Attribute("type", "software"));
    elCreator.appendChild("Live Notes");
    elID.appendChild(elCreator);
    elRoot.appendChild(elID);

    document = new Document(elRoot);
    document.insertChild(new DocType("score-partwise",
                                     "-//Recordare//DTD MusicXML 1.1 Partwise//EN",
                                     "http://www.musicxml.org/dtds/partwise.dtd"),
                         0);

    elRoot.appendChild(new Element("part-list"));
    doFirstMeasure();
}
 
開發者ID:joshschriever,項目名稱:LiveNotes,代碼行數:23,代碼來源:MusicXmlRenderer.java

示例3: saveDocument

import nu.xom.Document; //導入依賴的package包/類
public static void saveDocument(Document doc, String filePath) {
    /**
     * @todo: Configurable parameters
     */
    try {
        /*The XOM bug: reserved characters are not escaped*/
        //Serializer serializer = new Serializer(new FileOutputStream(filePath), "UTF-8");
        //serializer.write(doc);
        OutputStreamWriter fw =
            new OutputStreamWriter(new FileOutputStream(filePath), "UTF-8");
        fw.write(doc.toXML());
        fw.flush();
        fw.close();
    }
    catch (IOException ex) {
        new ExceptionDialog(
            ex,
            "Failed to write a document to " + filePath,
            "");
    }
}
 
開發者ID:ser316asu,項目名稱:Reinickendorf_SER316,代碼行數:22,代碼來源:FileStorage.java

示例4: process

import nu.xom.Document; //導入依賴的package包/類
@Override
public <T> T process(T xml, Iterable<Effect> effects) throws XmlBuilderException {
    if (!canHandle(xml)) {
        throw new IllegalArgumentException("XML model is not supported");
    }
    final Node xmlNode = (Node) xml;
    final XomNode<?> node;
    if (xmlNode instanceof Document) {
        node = new XomDocument((Document) xmlNode);
    } else if (xmlNode instanceof Element) {
        node = new XomElement((Element) xmlNode);
    } else if (xmlNode instanceof Attribute) {
        node = new XomAttribute((Attribute) xmlNode);
    } else {
        throw new IllegalArgumentException("XML node type is not supported");
    }
    final Navigator<XomNode> navigator = new XomNavigator(xmlNode);
    for (Effect effect : effects) {
        effect.perform(navigator, node);
    }
    return xml;
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:23,代碼來源:XomNavigatorSpi.java

示例5: shouldBuildDocumentFromSetOfXPathsAndSetValues

import nu.xom.Document; //導入依賴的package包/類
@Test
public void shouldBuildDocumentFromSetOfXPathsAndSetValues() throws XPathExpressionException, IOException {
    Map<String, Object> xmlProperties = fixtureAccessor.getXmlProperties();
    Document newDocument = new Document((Element) root.copy());
    Document builtDocument = new XmlBuilder(namespaceContext)
            .putAll(xmlProperties)
            .build(newDocument);

    for (Entry<String, Object> xpathToValuePair : xmlProperties.entrySet()) {
        Nodes nodes = null == namespaceContext
                ? builtDocument.query(xpathToValuePair.getKey())
                : builtDocument.query(xpathToValuePair.getKey(), toXpathContext(namespaceContext));
        assertThat(nodes.get(0).getValue()).isEqualTo(xpathToValuePair.getValue());
    }
    assertThat(xmlToString(builtDocument)).isEqualTo(fixtureAccessor.getPutValueXml());
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:17,代碼來源:XmlBuilderTest.java

示例6: shouldNotModifyDocumentWhenAllXPathsTraversable

import nu.xom.Document; //導入依賴的package包/類
@Test
public void shouldNotModifyDocumentWhenAllXPathsTraversable()
        throws XPathExpressionException, ParsingException, IOException {
    Map<String, Object> xmlProperties = fixtureAccessor.getXmlProperties();
    String xml = fixtureAccessor.getPutValueXml();
    Document oldDocument = stringToXml(xml);
    Document builtDocument = new XmlBuilder(namespaceContext)
            .putAll(xmlProperties)
            .build(oldDocument);

    assertThat(xmlToString(builtDocument)).isEqualTo(xml);

    builtDocument = new XmlBuilder(namespaceContext)
            .putAll(xmlProperties.keySet())
            .build(oldDocument);

    assertThat(xmlToString(builtDocument)).isEqualTo(xml);
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:19,代碼來源:XmlBuilderTest.java

示例7: getAllTags

import nu.xom.Document; //導入依賴的package包/類
public static Vector<String> getAllTags(){
	Document projects=FileStorage.openDocument(FileStorage.JN_DOCPATH + ".projects");
	Element root= new Element("projects-list");
	Elements prjs = projects.getRootElement().getChildElements("project");
	int number=0;
	ParentNode p=null;
	Vector<String> list=new Vector<String>();
    for (int i = 0; i < prjs.size(); i++) {
    	Elements tags =prjs.get(i).getFirstChildElement("tags").getChildElements();
    	for (int j = 0; j < tags.size(); j++){
    		list.add(tags.get(j).getAttributeValue("name"));
    	}
    }
    return list;
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:16,代碼來源:ProjectImpl.java

示例8: openDocument

import nu.xom.Document; //導入依賴的package包/類
public static Document openDocument(String filePath) {
    try {
        return openDocument(new FileInputStream(filePath));
    }
    catch (Exception ex) {
        new ExceptionDialog(
            ex,
            "Failed to read a document from " + filePath,
            "");
    }
    return null;
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:13,代碼來源:FileStorage.java

示例9: openTaskList

import nu.xom.Document; //導入依賴的package包/類
public TaskList openTaskList(Project prj) {
    String fn = JN_DOCPATH + prj.getID() + File.separator + ".tasklist";

    if (documentExists(fn)) {
        /*DEBUG*/
        System.out.println(
            "[DEBUG] Open task list: "
                + JN_DOCPATH
                + prj.getID()
                + File.separator
                + ".tasklist");
        
        Document tasklistDoc = openDocument(fn);
        /*DocType tasklistDoctype = tasklistDoc.getDocType();
        String publicId = null;
        if (tasklistDoctype != null) {
            publicId = tasklistDoctype.getPublicID();
        }
        boolean upgradeOccurred = TaskListVersioning.upgradeTaskList(publicId);
        if (upgradeOccurred) {
            // reload from new file
            tasklistDoc = openDocument(fn);
        }*/
        return new TaskListImpl(tasklistDoc, prj);   
    }
    else {
        /*DEBUG*/
        System.out.println("[DEBUG] New task list created");
        return new TaskListImpl(prj);
    }
}
 
開發者ID:ser316asu,項目名稱:SER316-Aachen,代碼行數:32,代碼來源:FileStorage.java

示例10: storePSP

import nu.xom.Document; //導入依賴的package包/類
/**
 * This method stores PSP data in Memoranda storage. 
 * @param psp PSP to save in project
 * @param prj Project to save the PSP information too. 
 */
public void storePSP(PSP psp, Project prj){
	 
        /*DEBUG*/
        System.out.println(
            "[DEBUG] Save psp: "
                + JN_DOCPATH
                + prj.getID()
                + File.separator
                + ".psp");
        Document pspDoc = psp.getXMLContent();
        //tasklistDoc.setDocType(TaskListVersioning.getCurrentDocType());
        saveDocument(pspDoc,JN_DOCPATH + prj.getID() + File.separator + ".psp");
}
 
開發者ID:ser316asu,項目名稱:Dahlem_SER316,代碼行數:19,代碼來源:FileStorage.java

示例11: shouldBuildDocumentFromSetOfXPaths

import nu.xom.Document; //導入依賴的package包/類
@Benchmark
public void shouldBuildDocumentFromSetOfXPaths(Blackhole blackhole)
        throws XPathExpressionException, IOException {
    Map<String, Object> xmlProperties = fixtureAccessor.getXmlProperties();
    Document newDocument = new Document((Element) root.copy());
    blackhole.consume(new XmlBuilder(namespaceContext)
            .putAll(xmlProperties.keySet())
            .build(newDocument));
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:10,代碼來源:XomXmlBuilderBenchmark.java

示例12: storeTaskList

import nu.xom.Document; //導入依賴的package包/類
public void storeTaskList(TaskList tasklist, Project prj) {
    /*DEBUG*/
    System.out.println(
        "[DEBUG] Save task list: "
            + JN_DOCPATH
            + prj.getID()
            + File.separator
            + ".tasklist");
    Document tasklistDoc = tasklist.getXMLContent();
    //tasklistDoc.setDocType(TaskListVersioning.getCurrentDocType());
    saveDocument(tasklistDoc,JN_DOCPATH + prj.getID() + File.separator + ".tasklist");
}
 
開發者ID:ser316asu,項目名稱:Dahlem_SER316,代碼行數:13,代碼來源:FileStorage.java

示例13: CommitListImpl

import nu.xom.Document; //導入依賴的package包/類
/**
   * Constructor for TaskListImpl.
   */
  public CommitListImpl(Document doc, Project prj) {
      _doc = doc;
      _root = _doc.getRootElement();
      _project = prj;
buildElements(_root);
  }
 
開發者ID:ser316asu,項目名稱:Wilmersdorf_SER316,代碼行數:10,代碼來源:CommitListImpl.java

示例14: serialize

import nu.xom.Document; //導入依賴的package包/類
/**
 * 
 * @param result
 * @return
 * @throws IOException 
 * @throws XProcRuntimeException 
 */
private String[] serialize(XProcResult result) throws XProcRuntimeException, IOException{
	Document[] docs = result.getDocuments();
	String[] serialized = new String[docs.length];
	SerializerOptions options = new SerializerOptions();
	options.put(SerializerOptions.Options.indent, "true");
	options.put(SerializerOptions.Options.omit_xml_declaration, "true");
	PortSerializer serializer = new PortSerializer(options, null);
	for (int i=0; i < docs.length; i++)
		serialized[i] = serializer.serializeToString(null, docs[i]);
	return serialized;
}
 
開發者ID:xml-project,項目名稱:support-for-xmleditor,代碼行數:19,代碼來源:Adapter.java

示例15: TaskListImpl

import nu.xom.Document; //導入依賴的package包/類
/**
   * Constructor for TaskListImpl.
   */
  public TaskListImpl(Document doc, Project prj) {
      _doc = doc;
      _root = _doc.getRootElement();
      _project = prj;
buildElements(_root);
  }
 
開發者ID:ser316asu,項目名稱:SER316-Ingolstadt,代碼行數:10,代碼來源:TaskListImpl.java


注:本文中的nu.xom.Document類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。