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


Java JAXB.unmarshal方法代码示例

本文整理汇总了Java中javax.xml.bind.JAXB.unmarshal方法的典型用法代码示例。如果您正苦于以下问题:Java JAXB.unmarshal方法的具体用法?Java JAXB.unmarshal怎么用?Java JAXB.unmarshal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.bind.JAXB的用法示例。


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

示例1: submitJButtonActionPerformed

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
private void submitJButtonActionPerformed(//GEN-FIRST:event_submitJButtonActionPerformed
   java.awt.event.ActionEvent evt)
{//GEN-HEADEREND:event_submitJButtonActionPerformed
   String name = nameJTextField.getText(); // get name from JTextField

   // the URL for the REST service
   String url = "http://localhost:8080/WelcomeRESTXML/" +
      "webresources/welcome/" + name;

   // read from URL and convert from XML to Java String
   String message = JAXB.unmarshal(url, String.class);

   // display the message to the user
   JOptionPane.showMessageDialog(this, message,
         "Welcome", JOptionPane.INFORMATION_MESSAGE);
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:17,代码来源:WelcomeRESTXMLClientJFrame.java

示例2: generateJButtonActionPerformed

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
private void generateJButtonActionPerformed(//GEN-FIRST:event_generateJButtonActionPerformed
   java.awt.event.ActionEvent evt)
{//GEN-HEADEREND:event_generateJButtonActionPerformed
   try
   {
      String url = String.format("http://localhost:8080/" +
         "EquationGeneratorXML/webresources/equation/%s/%d",
         operation, difficulty);

      // convert XML back to an Equation object
      Equation equation = JAXB.unmarshal(url, Equation.class);

      answer = equation.getResult();
      equationJLabel.setText(equation.getLeftHandSide() + " =");
      checkAnswerJButton.setEnabled(true);
   } 
   catch (Exception exception)
   {
      exception.printStackTrace();
   } 
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:22,代码来源:EquationGeneratorXMLClientJFrame.java

示例3: StringReader

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
/**
 * スキーマのスキーマ情報を取得するテスト$metadata_$metadata.
 */
@Test
public final void スキーマのスキーマ情報を取得するテスト$metadata_$metadata() {

    TResponse res = Http.request("box/$metadata-$metadata-get.txt")
            .with("path", "\\$metadata/\\$metadata")
            .with("col", "setodata")
            .with("accept", "application/xml")
            .with("token", PersoniumUnitConfig.getMasterToken())
            .returns()
            .statusCode(HttpStatus.SC_OK)
            .debug();

    // レスポンスボディーのチェック
    String str = res.getBody();

    Edmx edmx = JAXB.unmarshal(new StringReader(str), Edmx.class);
    Edmx checkBody = getRightEdmx();
    assertTrue(checkBody.equals(edmx));
}
 
开发者ID:personium,项目名称:personium-core,代码行数:23,代码来源:ServiceSchmaTest.java

示例4: actionPerformed

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
@Override
public void actionPerformed( final ActionEvent event ) {
 final XFileChooser fc = new XFileChooser( SAVE_FOLDER );
 fc.setDialogTitle( "Choose a file to load Replay Filters from" );
 fc.setFileFilter( new FileNameExtensionFilter( "Replay Filter files (*."
         + REP_FILTERS_FILE_EXT + ")", REP_FILTERS_FILE_EXT ) );
 
 if ( XFileChooser.APPROVE_OPTION != fc.showOpenDialog( RepFiltersEditorDialog.this ) )
  return;
 
 try {
  repFiltersBean = JAXB
          .unmarshal( fc.getSelectedPath().toFile(), RepFiltersBean.class );
  if ( rfBean != null )
   rfBean.setRepFiltersBean( (RepFiltersBean) repFiltersBean );
 } catch ( final Exception e ) {
  Env.LOGGER.error(
          "Failed to load Replay filters from file: " + fc.getSelectedPath(), e );
  GuiUtils.showErrorMsg( "Failed to load Replay filters from file file:",
          fc.getSelectedPath() );
  return;
 }
 rebuildTable();
}
 
开发者ID:icza,项目名称:scelight,代码行数:25,代码来源:RepFiltersEditorDialog.java

示例5: readIndexParamsFromFile

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
public void readIndexParamsFromFile(String indexParamFile){
    try {
        p = JAXB.unmarshal(new File(indexParamFile), IndexParams.class);
    } catch (Exception e){
        e.printStackTrace();
        System.exit(1);
    }

    if(p.recordPositions==null)
        p.recordPositions=false;

    System.out.println("Index type: " + p.indexType);
    System.out.println("Path to index: " + p.indexName);
    System.out.println("List of files to index: " + p.fileList);
    System.out.println("Record positions in index: " + p.recordPositions);

}
 
开发者ID:lucene4ir,项目名称:lucene4ir,代码行数:18,代码来源:IndexerApp.java

示例6: testDublinCoreRecord

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
@Test
    public void testDublinCoreRecord() throws Exception {
        ObjectMapper om = new JacksonProvider().getContext(DublinCoreRecord.class);
        om.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
        URL resource = JacksonProviderTest.class.getResource("dc_test.xml");
        assertNotNull(resource);
        OaiDcType dc = JAXB.unmarshal(resource, OaiDcType.class);
        DublinCoreRecord dr = new DublinCoreRecord(dc, System.currentTimeMillis(), "uuid:1");
        String toJson = om.writeValueAsString(dr);
//        System.out.println(toJson);

        DublinCoreRecord ndr = om.readValue(toJson, DublinCoreRecord.class);
        assertEquals(dr.getBatchId(), ndr.getBatchId());
        assertEquals(dr.getPid(), ndr.getPid());
        assertEquals(dr.getTimestamp(), ndr.getTimestamp());
        assertEquals(dr.getDc().getIdentifiers(), ndr.getDc().getIdentifiers());
        assertEquals(dr.getDc().getTitles(), ndr.getDc().getTitles());
        assertEquals(dr.getDc().getCreators(), ndr.getDc().getCreators());

        StringWriter toXml = new StringWriter();
        DcUtils.marshal(new StreamResult(toXml), ndr.getDc(), true);
        toXml.flush();
//        System.out.println("---");
//        System.out.println(toXml);
    }
 
开发者ID:proarc,项目名称:proarc,代码行数:26,代码来源:JacksonProviderTest.java

示例7: handleUiResource

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
/**
 * 
 * @since 1.0
 * @param context
 * @param component
 * @param annotate
 */
@UiAnnotationHandler(UiResource.class)
void handleUiResource(final ComponentContext context,
		final JList component, final UiResource annotate) {

	final InputStream in = this.getClass().getClassLoader()
			.getResourceAsStream(annotate.value());

	if (in == null) {
		LOGGER.error("{}|resource {} not found", context.getId(),
				annotate.value());
		return;
	}

	final ListInfo info = JAXB.unmarshal(in, ListInfo.class);

	component.setListData(info.getItems().toArray());
	LOGGER.debug("{}|JList.setListData(count={})", context.getId(), info
			.getItems().size());
}
 
开发者ID:kennycyb,项目名称:java-ui-factory,代码行数:27,代码来源:JListFactory.java

示例8: signJAXBObject

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
private <T> T signJAXBObject(T jaxbObj) {
        DOMResult domResult = new DOMResult();
        JAXB.marshal(jaxbObj, domResult);
        Document doc = ((Document) domResult.getNode());
        Element docElement = doc.getDocumentElement();

        try {
                KeyStore ks = KeyStore.getInstance(SIGNATURE_KEYSTORE_TYPE);
                URL url = Thread.currentThread().getContextClassLoader().getResource(SIGNATURE_KEYSTORE);
                ks.load(url.openStream(), SIGNATURE_KEYSTORE_PASSWORD.toCharArray());
                KeyStore.PrivateKeyEntry keyEntry = (KeyStore.PrivateKeyEntry) ks.getEntry(SIGNATURE_KEYSTORE_ALIAS, new KeyStore.PasswordProtection(SIGNATURE_KEYSTORE_PASSWORD.toCharArray()));
                PrivateKey privateKey = keyEntry.getPrivateKey();
                Certificate origCert = keyEntry.getCertificate();
                PublicKey validatingKey = origCert.getPublicKey();
                TckSigningUtil.signDOM(docElement, privateKey, origCert);

                DOMSource domSource = new DOMSource(doc);
                T result = (T) JAXB.unmarshal(domSource, jaxbObj.getClass());
                return result;
        } catch (Exception e) {
                throw new RuntimeException("Signature failure due to: " + e.getMessage(), e);
        }
}
 
开发者ID:apache,项目名称:juddi,代码行数:24,代码来源:TckBusiness.java

示例9: load

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
/**
 * Loads the memorized tab.
 *
 * @return the glyph definitions
 */
public GlyphDefinitions load() {
    File file = new File(pathName + "/" + fileName);
    GlyphDefinitions glyphDefinitions = null;

    if (file.exists()) {
        try {
            glyphDefinitions = JAXB.unmarshal(file, GlyphDefinitions.class);
        } catch (DataBindingException e) {
            LOGGER.error("Error unmarshalling user data.", e);
        }
    }

    if (glyphDefinitions == null) {
        glyphDefinitions = new GlyphDefinitions();
    }
    return glyphDefinitions;
}
 
开发者ID:richard-strauss-werke,项目名称:glyphpicker,代码行数:23,代码来源:MemorizedCharactersLoader.java

示例10: createStdOutReader

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
protected StdReader<FFprobeResult> createStdOutReader() {
    return new StdReader<FFprobeResult>() {
        @Override
        public FFprobeResult read(InputStream stdOut) {
            return JAXB.unmarshal(stdOut, FFprobeResult.class);
        }
    };
}
 
开发者ID:kokorin,项目名称:Jaffree,代码行数:9,代码来源:FFprobe.java

示例11: getExistingEcmExtensions

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
private static Node getExistingEcmExtensions(final File sourcePath) {
    final File extensions = new File(sourcePath, ECM_EXTENSIONS_NAME);
    if (extensions.exists()) {
        return JAXB.unmarshal(extensions, Node.class);
    }
    return null;
}
 
开发者ID:openweb-nl,项目名称:hippo-groovy-updater,代码行数:8,代码来源:XmlGenerator.java

示例12: jaxbTest

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
@Test
public void jaxbTest() throws Exception {

    final ErrorResponse response = new ErrorResponse(new IOException("ahem"), mock(UriInfo.class), true);
    final StringWriter writer = new StringWriter();
    JAXB.marshal(response, writer);
    final ErrorResponse unmarshaled = JAXB.unmarshal(new StringReader(writer.toString()), ErrorResponse.class);
    assertEquals(response.getError(), unmarshaled.getError());

}
 
开发者ID:trajano,项目名称:app-ms,代码行数:11,代码来源:ErrorResponseTest.java

示例13: getExtensions

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
/**
 * Reads extensions from classpath and combines them.
 *
 * @return combined list of extensions.
 *
 * @throws IOException
 */
public static List<ExtensionDescriptor> getExtensions() throws IOException {
    List<ExtensionDescriptor> descriptors = new ArrayList<>();
    Enumeration<URL> extensionFiles = Thread.currentThread().getContextClassLoader().getResources(LOCATION);
    while (extensionFiles.hasMoreElements()) {
        URL extensionFile = extensionFiles.nextElement();
        ExtensionDescriptorWrapper extensionDescriptorWrapper = JAXB.unmarshal(extensionFile, ExtensionDescriptorWrapper.class);
        descriptors.addAll(extensionDescriptorWrapper.getExtensions());
    }
    return descriptors;
}
 
开发者ID:cloudogu,项目名称:annotation-processors,代码行数:18,代码来源:Extensions.java

示例14: testJAXB

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
@Test
public void testJAXB() {
    StringWriter writer = new StringWriter();
    action.filter();
    JAXB.marshal(action, writer);
    TlsAction action2 = JAXB.unmarshal(new StringReader(writer.getBuffer().toString()), ReceiveAction.class);
    action.normalize();
    action2.normalize();
    assertThat(action, equalTo(action2));
}
 
开发者ID:RUB-NDS,项目名称:TLS-Attacker,代码行数:11,代码来源:ReceiveActionTest.java

示例15: marshalingAndUnmarshalingYieldsEqualObject

import javax.xml.bind.JAXB; //导入方法依赖的package包/类
@Test
public void marshalingAndUnmarshalingYieldsEqualObject() {
    action = new ForwardAction(ctx1Alias, ctx2Alias, new ClientHelloMessage());
    // action.filter();
    StringWriter writer = new StringWriter();
    JAXB.marshal(action, writer);
    TlsAction actual = JAXB.unmarshal(new StringReader(writer.getBuffer().toString()), ForwardAction.class);
    assertEquals(action, actual);
}
 
开发者ID:RUB-NDS,项目名称:TLS-Attacker,代码行数:10,代码来源:ForwardActionTest.java


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