当前位置: 首页>>代码示例>>Java>>正文


Java Document类代码示例

本文整理汇总了Java中com.google.gwt.xml.client.Document的典型用法代码示例。如果您正苦于以下问题:Java Document类的具体用法?Java Document怎么用?Java Document使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Document类属于com.google.gwt.xml.client包,在下文中一共展示了Document类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadStructure

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
private void loadStructure(final JavaScriptObject assessmentData, final JavaScriptObject itemDatas) {
    GWT.runAsync(new RunAsyncCallback() {
        @Override
        public void onSuccess() {
            Document assessmentDoc = XMLParser.parse(decodeXmlDataDocument(assessmentData));
            XmlData assessmentXmlData = new XmlData(assessmentDoc, decodeXmlDataBaseURL(assessmentData));

            JsArray<JavaScriptObject> itemDatasArray = itemDatas.cast();

            XmlData itemXmlDatas[] = new XmlData[itemDatasArray.length()];
            for (int i = 0; i < itemDatasArray.length(); i++) {
                Document itemDoc = XMLParser.parse(decodeXmlDataDocument(itemDatasArray.get(i)));
                itemXmlDatas[i] = new XmlData(itemDoc, decodeXmlDataBaseURL(itemDatasArray.get(i)));
            }
            player = playerFactory.createPlayer(node_id, jsObject);
            player.load(assessmentXmlData, itemXmlDatas);
        }

        @Override
        public void onFailure(Throwable reason) {
            throw new RuntimeException("Error while loading player!", reason);
        }
    });
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:25,代码来源:PlayerLoader.java

示例2: loadMainDocument

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
public void loadMainDocument(String url) {
    if (mode == DataSourceManagerMode.LOADING_ASSESSMENT || mode == DataSourceManagerMode.LOADING_ITEMS || "".equals(url)) {
        return;
    }

    mode = DataSourceManagerMode.LOADING_ASSESSMENT;

    String resolvedURL;

    resolvedURL = PathUtil.resolvePath(url, GWT.getHostPageBaseURL());

    new eu.ydp.empiria.player.client.util.file.xml.XmlDocument(resolvedURL, new DocumentLoadCallback<Document>() {

        @Override
        public void finishedLoading(Document document, String baseURL) {
            assesmentXML = new XmlData(document, baseURL);
            assessmentDataManager.initializeAssessmentData(assesmentXML);
        }

        @Override
        public void loadingError(String error) {
            assessmentDataManager.setAssessmentLoadingError(error);
            onLoadFinished();
        }
    });
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:27,代码来源:DataSourceManager.java

示例3: loadExtensionsLibrary

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
private void loadExtensionsLibrary() {
    String libraryUrl = assessmentDataManager.getLibraryLink();

    new XmlDocument(libraryUrl, new DocumentLoadCallback<Document>() {

        @Override
        public void finishedLoading(Document document, String baseURL) {
            libraryLoader.load(new XmlData(document, baseURL));
        }

        @Override
        public void loadingError(String error) {
            onExtensionsLoadFinished();
        }
    });

}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:18,代码来源:DataSourceManager.java

示例4: Assessment

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
/**
 * C'tor
 *
 * @param data XMLData object as data source
 */
@Inject
public Assessment(@Assisted AssessmentData data, @Assisted DisplayContentOptions options, @Assisted ModulesRegistrySocket modulesRegistrySocket,
                  AssessmentFactory assessmentFactory, InlineBodyGeneratorFactory inlineBodyGeneratorFactory) {

    this.assessmentFactory = assessmentFactory;
    this.inlineBodyGeneratorFactory = inlineBodyGeneratorFactory;
    this.xmlData = data.getData();

    this.modulesRegistrySocket = modulesRegistrySocket;
    this.options = options;

    Document document = xmlData.getDocument();
    Element rootNode = (Element) document.getElementsByTagName("assessmentTest").item(0);
    Element skinBody = getSkinBody(data.getSkinData());

    if (skinBody == null) {
        skinBody = XMLParser.parse("<itemBody><pageInPage /></itemBody>").getDocumentElement();
    }

    styleDeclaration = new StyleLinkDeclaration(xmlData.getDocument().getElementsByTagName("styleDeclaration"), xmlData.getBaseURL());
    title = rootNode.getAttribute("title");

    initializeBody(skinBody);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:30,代码来源:Assessment.java

示例5: XmlDocument

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
public XmlDocument(String url, DocumentLoadCallback<Document> callback) {

        this.callback = callback;
        this.url = url;

        new TextDocument(this.url, new DocumentLoadCallback<String>() {

            @Override
            public void loadingError(String message) {
                XmlDocument.this.callback.loadingError(message);
            }

            @Override
            public void finishedLoading(String text, String baseUrl) {
                try {
                    Document dom = XMLParser.parse(text);
                    XmlDocument.this.callback.finishedLoading(dom, baseUrl);
                } catch (DOMParseException e) {
                    e.printStackTrace();
                    XmlDocument.this.callback.loadingError("Could not parse file: " + XmlDocument.this.url);
                }
            }
        });

    }
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:26,代码来源:XmlDocument.java

示例6: fix

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
@Deprecated
private void fix(Document document, String baseUrl) {

    fixLinks(document, baseUrl, "img", SRC_TAG);
    fixLinks(document, baseUrl, "img", "srcFullScreen");
    fixLinks(document, baseUrl, "embed", SRC_TAG);
    fixLinks(document, baseUrl, "sound", SRC_TAG);
    fixLinks(document, baseUrl, "video", SRC_TAG);
    fixLinks(document, baseUrl, "object", "poster");
    fixLinks(document, baseUrl, "source", SRC_TAG);
    fixLinks(document, baseUrl, "a", "href");
    fixLinks(document, baseUrl, "button", "href");
    fixLinks(document, baseUrl, "object", "data");
    fixLinks(document, baseUrl, "audioPlayer", "data");
    fixLinks(document, baseUrl, "audioPlayer", SRC_TAG);
    fixLinks(document, baseUrl, "vocaItem", SRC_TAG);
    fixLinks(document, baseUrl, "flash", SRC_TAG);
    fixLinks(document, baseUrl, "simulationPlayer", SRC_TAG);
    fixLinks(document, baseUrl, "showUrl", "href");
    fixLinks(document, baseUrl, "image", SRC_TAG);
    fixLinks(document, baseUrl, "correctImage", SRC_TAG);
    fixLinks(document, baseUrl, "video", "poster");
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:24,代码来源:XmlData.java

示例7: fixLinks

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
/**
 * Fix links relative to xml file
 *
 * @param tagName  tag name
 * @param attrName attribute name with link
 */
private void fixLinks(Document document, String baseUrl, String tagName, String attrName) {

    NodeList nodes = document.getElementsByTagName(tagName);

    for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        String link = element.getAttribute(attrName);
        if (link != null && !link.startsWith("http")) {
            element.setAttribute(attrName, baseUrl + link);
        }
        // Links open in new window
        if (tagName.compareTo("a") == 0) {
            element.setAttribute("target", "_blank");
        }
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:23,代码来源:XmlData.java

示例8: testIsStylesAreNotCorrect

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test(expected = CssStyleException.class)
public void testIsStylesAreNotCorrect() {
    styles.put("display", "table-cell");
    styles.put("width", "20px");

    Document document = mock(Document.class);
    Element element = mock(Element.class);
    when(document.getDocumentElement()).thenReturn(element);
    when(xmlParser.parse("<root><styleTest class=\"styleTest\"/></root>")).thenReturn(document);

    instance.cssClassNames.add("styleTest");
    when(cssHelper.checkIfEquals(any(Map.class), eq("display"), eq("table-cell"))).thenReturn(true);

    instance.areStylesCorrectThrowsExceptionWhenNot(null);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:17,代码来源:ConnectionStyleCheckerJUnitTest.java

示例9: before

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
@Before
public void before() {
    XMLParser parser = mock(XMLParser.class);
    styleNames = mock(ConnectionStyleNameConstants.class);
    when(styleNames.QP_CONNECTION_WRONG()).thenReturn("qp-connection-wrong");
    when(styleNames.QP_CONNECTION_CORRECT()).thenReturn("qp-connection-correct");
    when(styleNames.QP_CONNECTION_DISABLED()).thenReturn("qp-connection-disabled");
    when(styleNames.QP_CONNECTION_NORMAL()).thenReturn("qp-connection-normal");

    styles.put(MultiplePairModuleConnectType.WRONG, styleNames.QP_CONNECTION_WRONG());
    styles.put(MultiplePairModuleConnectType.CORRECT, styleNames.QP_CONNECTION_CORRECT());
    styles.put(MultiplePairModuleConnectType.NONE, styleNames.QP_CONNECTION_DISABLED());
    styles.put(MultiplePairModuleConnectType.NORMAL, styleNames.QP_CONNECTION_NORMAL());
    when(parser.parse(Matchers.anyString())).then(new Answer<Document>() {
        @Override
        public Document answer(InvocationOnMock invocation) throws Throwable {
            return eu.ydp.gwtutil.xml.XMLParser.parse((String) invocation.getArguments()[0]);
        }
    });
    testObj = new ConnectionStyleXMLElementCache(styleNames, parser);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:22,代码来源:ConnectionStyleXMLElementCacheTest.java

示例10: testGetBoolean_false

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
@Test
public void testGetBoolean_false() {

    Document document = mock(Document.class);
    Element firstChild = mock(Element.class);
    Element element = mock(Element.class);
    when(document.getDocumentElement()).thenReturn(element);
    when(element.getFirstChild()).thenReturn(firstChild);
    String xmlConntent = "<root><nodeName class=\"nodeName\"/></root>";
    when(xmlParser.parse(xmlConntent)).thenReturn(document);
    Map<String, String> map = new HashMap<String, String>();
    map.put("attribute", "false");
    when(styleSocket.getStyles(firstChild)).thenReturn(map);

    boolean attribute = instance.getBoolean("nodeName", "attribute");

    assertFalse(attribute);

    InOrder inOrder = inOrder(styleSocket, xmlParser);
    inOrder.verify(xmlParser).parse(xmlConntent);
    inOrder.verify(styleSocket).getStyles(firstChild);

}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:24,代码来源:StyleAttributeHelperTest.java

示例11: testGetBoolean_true

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
@Test
public void testGetBoolean_true() {

    Document document = mock(Document.class);
    Element firstChild = mock(Element.class);
    Element element = mock(Element.class);
    when(document.getDocumentElement()).thenReturn(element);
    when(element.getFirstChild()).thenReturn(firstChild);
    String xmlConntent = "<root><nodeName class=\"nodeName\"/></root>";
    when(xmlParser.parse(xmlConntent)).thenReturn(document);
    Map<String, String> map = new HashMap<String, String>();
    map.put("attribute", "true");
    when(styleSocket.getStyles(firstChild)).thenReturn(map);

    boolean attribute = instance.getBoolean("nodeName", "attribute");

    assertTrue(attribute);

    InOrder inOrder = inOrder(styleSocket, xmlParser);
    inOrder.verify(xmlParser).parse(xmlConntent);
    inOrder.verify(styleSocket).getStyles(firstChild);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:23,代码来源:StyleAttributeHelperTest.java

示例12: testStylesForDifferentPages

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
public void testStylesForDifferentPages() {
    scriptsLoader.inject(new SynchronousScriptsCallback() {
        @Override
        public void onLoad() {

            testObj.addAssessmentStyle(new StyleDocument(CssParser.parseCss(css1), ""));
            testObj.addItemStyle(0, new StyleDocument(CssParser.parseCss(css2), ""));
            testObj.addItemStyle(1, new StyleDocument(CssParser.parseCss(css3), ""));
            testObj.setCurrentPages(new PageReference(PageType.TEST, new int[]{0}, null, null));

            Document doc = XMLParser.parse("<h2 />");
            Element e = doc.getDocumentElement();
            Map<String, String> styles = testObj.getStyleProperties(e, true);
            assertTrue(styles.containsKey("font-size"));
            assertFalse(styles.containsKey("font-weight"));

            testObj.setCurrentPages(new PageReference(PageType.TEST, new int[]{1}, null, null));
            doc = XMLParser.parse("<h1 />");
            e = doc.getDocumentElement();
            styles = testObj.getStyleProperties(e, true);
            assertFalse(styles.containsKey("font-size"));
            assertTrue(styles.containsKey("font-weight"));
            finishTest();
        }
    });
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:27,代码来源:StyleDataSourceManagerGWTTestCase.java

示例13: testXmlProcessing

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
public void testXmlProcessing() {

        Document doc = XMLParser
                .parse("<nodes><responseDeclaration identifier='RESPONSE' cardinality='multiple' baseType='identifier'><correctResponse><value>ChoiceA</value></correctResponse></responseDeclaration></nodes>");

        VariableManager<CustomVariable> vm = new VariableManager<CustomVariable>(doc.getDocumentElement().getChildNodes(),

                new IVariableCreator<CustomVariable>() {

                    @Override
                    public CustomVariable createVariable(Node node) {
                        assertTrue(node.getNodeType() == Node.ELEMENT_NODE);
                        Element el = (Element) node;
                        String identifier = el.getAttribute("identifier");
                        assertEquals("RESPONSE", identifier);
                        return new CustomVariable();
                    }
                }

        );

        assertTrue(vm.getVariableIdentifiers().size() == 1);
        assertTrue(vm.getVariable("RESPONSE") instanceof CustomVariable);
    }
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:25,代码来源:VariableManagerGWTTestCase.java

示例14: parse

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
/**
 * @param wadlXmlString
 */
public void parse(String wadlXmlString) {
  // remove unnecessary whitespaces
  wadlXmlString = wadlXmlString.replaceAll(">\\s*<", "><");
  //  remove <!-- comment nodes -->
  wadlXmlString = wadlXmlString.replaceAll("<!--.*?-->", "");    
  try {
    // reset the application
    GuiFactory.resetApplication();
    
    Document wadl = XMLParser.parse(wadlXmlString);
    
    if (startParsing(wadl)) {
      uploadDialogBox.setVisible(true);
      uploadDialogBox.hide();
      // if the parsing succeeded render a tree from the parsed wadl    
      WadlTreeRoot wadlTreeRoot = new WadlTreeRoot();
      Tree wadlTree = wadlTreeRoot.buildTree(application);       
      WadlPanel.wadlArea.setWidget(wadlTree);
      GuiFactory.toggleButtonsEnabled(true);
      WadlPanel.fullscreenButton.click();
    }
  } catch (DOMParseException e) {
    alertInvalidWadlAndRetry(GuiFactory.strings.invalidWadl());
  }    
}
 
开发者ID:tomayac,项目名称:rest-describe-and-compile,代码行数:29,代码来源:WadlParser.java

示例15: deserializeAsCollection

import com.google.gwt.xml.client.Document; //导入依赖的package包/类
/**
 * Deserialize the plain text into an object of type T.
 *
 * @param collectionType The class of the collection
 * @param response       Http response body content
 * @param context        Context of deserialization
 *
 * @return The object deserialized
 */
@Override
public <C extends Collection<Book>> C deserializeAsCollection(Class<C> collectionType, String response,
                                                              DeserializationContext context) {
    C col = context.getContainerInstance(collectionType);

    Document xml;
    try {
        xml = XMLParser.parse(response);
    } catch (DOMParseException e) {
        throw new UnableToDeserializeException("Could not read response as xml.", e);
    }

    Collections.addAll(col, parseXmlDocumentAsBook(xml));

    return col;
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:26,代码来源:BookXmlSerdes.java


注:本文中的com.google.gwt.xml.client.Document类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。