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


Java JAXBException類代碼示例

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


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

示例1: unmarshal

import javax.xml.bind.JAXBException; //導入依賴的package包/類
@Override
public <T> JAXBElement<T> unmarshal( Source source, Class<T> expectedType ) throws JAXBException {
    if (source instanceof SAXSource) {
        SAXSource ss = (SAXSource) source;

        XMLReader locReader = ss.getXMLReader();
        if (locReader == null) {
            locReader = getXMLReader();
        }

        return unmarshal(locReader, ss.getInputSource(), expectedType);
    }
    if (source instanceof StreamSource) {
        return unmarshal(getXMLReader(), streamSourceToInputSource((StreamSource) source), expectedType);
    }
    if (source instanceof DOMSource) {
        return unmarshal(((DOMSource) source).getNode(), expectedType);
    }

    // we don't handle other types of Source
    throw new IllegalArgumentException();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:UnmarshallerImpl.java

示例2: test

import javax.xml.bind.JAXBException; //導入依賴的package包/類
public static void test() throws JAXBException {
    System.clearProperty(JAXBContext.JAXB_CONTEXT_FACTORY);
    System.out.println(JAXBContext.JAXB_CONTEXT_FACTORY + " = "
            + System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY, ""));
    System.out.println("Calling "
            + "JAXBContext.newInstance(JAXBContextWithAbstractFactory.class)");
    tmp = JAXBContext.newInstance(JAXBContextWithAbstractFactory.class);
    System.setProperty(JAXBContext.JAXB_CONTEXT_FACTORY,
            "JAXBContextWithAbstractFactory$Factory");
    System.out.println(JAXBContext.JAXB_CONTEXT_FACTORY + " = "
            + System.getProperty(JAXBContext.JAXB_CONTEXT_FACTORY));
    System.out.println("Calling "
            + "JAXBContext.newInstance(JAXBContextWithAbstractFactory.class)");
    JAXBContext ctxt = JAXBContext.newInstance(JAXBContextWithAbstractFactory.class);
    System.out.println("Successfully loaded JAXBcontext: " +
            System.identityHashCode(ctxt) + "@" + ctxt.getClass().getName());
    if (ctxt != tmp) {
        throw new RuntimeException("Wrong JAXBContext instance"
            + "\n\texpected: "
            + System.identityHashCode(tmp) + "@" + tmp.getClass().getName()
            + "\n\tactual:   "
            + System.identityHashCode(ctxt) + "@" + ctxt.getClass().getName());
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:JAXBContextWithAbstractFactory.java

示例3: testSimpleScannerXMLWithLabelsThatReceivesNoData

import javax.xml.bind.JAXBException; //導入依賴的package包/類
@Test
public void testSimpleScannerXMLWithLabelsThatReceivesNoData() throws IOException, JAXBException {
  final int BATCH_SIZE = 5;
  // new scanner
  ScannerModel model = new ScannerModel();
  model.setBatch(BATCH_SIZE);
  model.addColumn(Bytes.toBytes(COLUMN_1));
  model.addLabel(PUBLIC);
  StringWriter writer = new StringWriter();
  marshaller.marshal(model, writer);
  byte[] body = Bytes.toBytes(writer.toString());
  // recall previous put operation with read-only off
  conf.set("hbase.rest.readonly", "false");
  Response response = client.put("/" + TABLE + "/scanner", Constants.MIMETYPE_XML, body);
  assertEquals(response.getCode(), 201);
  String scannerURI = response.getLocation();
  assertNotNull(scannerURI);

  // get a cell set
  response = client.get(scannerURI, Constants.MIMETYPE_XML);
  // Respond with 204 as there are no cells to be retrieved
  assertEquals(response.getCode(), 204);
  assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type"));
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:25,代碼來源:TestScannersWithLabels.java

示例4: parse

import javax.xml.bind.JAXBException; //導入依賴的package包/類
public void parse() throws SAXException {
    // parses a content object by using the given marshaller
    // SAX events will be sent to the repeater, and the repeater
    // will further forward it to an appropriate component.
    try {
        marshaller.marshal( contentObject, (XMLFilterImpl)repeater );
    } catch( JAXBException e ) {
        // wrap it to a SAXException
        SAXParseException se =
            new SAXParseException( e.getMessage(),
                null, null, -1, -1, e );

        // if the consumer sets an error handler, it is our responsibility
        // to notify it.
        if(errorHandler!=null)
            errorHandler.fatalError(se);

        // this is a fatal error. Even if the error handler
        // returns, we will abort anyway.
        throw se;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:JAXBSource.java

示例5: SchemaInfo

import javax.xml.bind.JAXBException; //導入依賴的package包/類
/**
 * Initializes a new instance of the <see cref="SchemaInfo"/> class.
 */
public SchemaInfo(ResultSet reader,
        int offset) {
    try (StringReader sr = new StringReader(reader.getSQLXML(offset).getString())) {
        JAXBContext jc = JAXBContext.newInstance(SchemaInfo.class);

        XMLInputFactory xif = XMLInputFactory.newFactory();
        xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
        xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
        XMLStreamReader xsr = xif.createXMLStreamReader(sr);

        SchemaInfo schemaInfo = (SchemaInfo) jc.createUnmarshaller().unmarshal(xsr);

        this.referenceTables = new ReferenceTableSet(schemaInfo.getReferenceTables());
        this.shardedTables = new ShardedTableSet(schemaInfo.getShardedTables());
    }
    catch (SQLException | JAXBException | XMLStreamException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
 
開發者ID:Microsoft,項目名稱:elastic-db-tools-for-java,代碼行數:24,代碼來源:SchemaInfo.java

示例6: showMasterDetailInWindow

import javax.xml.bind.JAXBException; //導入依賴的package包/類
private void showMasterDetailInWindow(final Stage stage, final Database database, final MasterDetailViewFeatures features) throws JAXBException, IOException {
    final Parent viewRoot = ViewFactory.createMasterDetailView(database, features);

    final Rectangle clip = new Rectangle();
    clip.setArcHeight(18);
    clip.setArcWidth(18);
    clip.widthProperty().bind(stage.widthProperty());
    clip.heightProperty().bind(stage.heightProperty());

    //TODO: Only clipping or PerspectiveCamera is working... :(
    features.customWindowClipProperty().addListener((obs, oldVal, newVal) -> {
        if (newVal) {
            viewRoot.setClip(clip);
        } else {
            viewRoot.setClip(null);
        }
    });

    final Scene scene = new Scene(viewRoot);

    features.useCssProperty().addListener((obs, oldVal, newVal) -> {
        updateStylesheets(scene, newVal);
    });

    updateStylesheets(scene, features.isUseCss());

    scene.setFill(Color.TRANSPARENT);
    scene.setCamera(new PerspectiveCamera());

    if (features.isCustomWindowUI()) {
        stage.initStyle(StageStyle.TRANSPARENT);
    }

    stage.setTitle("Movie Database");
    stage.setScene(scene);
    stage.setWidth(1100);
    stage.setHeight(720);
    stage.centerOnScreen();
    stage.show();

    final FeaturesDialog featuresDialog = new FeaturesDialog(stage);
    featuresDialog.addFeature(new Feature("Layout & Style", "demo2-css", features.useCssProperty()));
    featuresDialog.addFeature(new Feature("Image Background", "demo2-image-background",features.movieBackgroundProperty()));
    featuresDialog.addFeature(new Feature("List Animation", "demo2-list-animation",features.listAnimationProperty()));
    featuresDialog.addFeature(new Feature("List Shadow", "demo2-list-shadow",features.listShadowProperty()));
    // featuresDialog.addFeature(new Feature("List Cache", "demo2-list-cache",features.listCacheProperty()));
    featuresDialog.addFeature(new Feature("Poster Transform", "demo2-poster-transform",features.posterTransformProperty()));
    featuresDialog.addFeature(new Feature("Custom Window UI", "demo2-custom-window-ui",features.customWindowUIProperty()));
    featuresDialog.addFeature(new Feature("Custom Window Clip", "demo2-custom-window-clip", features.customWindowClipProperty()));
    featuresDialog.show();
}
 
開發者ID:hendrikebbers,項目名稱:ExtremeGuiMakeover,代碼行數:52,代碼來源:MovieApp.java

示例7: createContext

import javax.xml.bind.JAXBException; //導入依賴的package包/類
/**
 * The JAXB API will invoke this method via reflection
 */
public static JAXBContext createContext( String contextPath,
                                         ClassLoader classLoader, Map properties ) throws JAXBException {

    List<Class> classes = new ArrayList<Class>();
    StringTokenizer tokens = new StringTokenizer(contextPath,":");

    // each package should be pointing to a JAXB RI generated
    // content interface package.
    //
    // translate them into a list of private ObjectFactories.
    try {
        while(tokens.hasMoreTokens()) {
            String pkg = tokens.nextToken();
            classes.add(classLoader.loadClass(pkg+IMPL_DOT_OBJECT_FACTORY));
        }
    } catch (ClassNotFoundException e) {
        throw new JAXBException(e);
    }

    // delegate to the JAXB provider in the system
    return JAXBContext.newInstance(classes.toArray(new Class[classes.size()]),properties);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:26,代碼來源:JAXBContextFactory.java

示例8: createTestCollection

import javax.xml.bind.JAXBException; //導入依賴的package包/類
/**
 * テスト用のコレクションを作成し、テストに必要なAccountやACLの設定を作成する.
 * @throws JAXBException リクエストに設定したACLの定義エラー
 */
private void createTestCollection() throws JAXBException {

    // Collection作成
    CellUtils.create(CELL_NAME, MASTER_TOKEN, HttpStatus.SC_CREATED);
    BoxUtils.create(CELL_NAME, BOX_NAME, MASTER_TOKEN, HttpStatus.SC_CREATED);
    DavResourceUtils.createServiceCollection(AbstractCase.BEARER_MASTER_TOKEN, HttpStatus.SC_CREATED, CELL_NAME,
            BOX_NAME, PARENT_COL_NAME);
    DavResourceUtils.createWebDavFile(MASTER_TOKEN, CELL_NAME,
            BOX_NAME + "/" + PARENT_COL_NAME + "/" + TARGET_SOURCE_FILE_PATH, "testFileBody",
            MediaType.TEXT_PLAIN,
            HttpStatus.SC_CREATED);

    // Role作成
    RoleUtils.create(CELL_NAME, MASTER_TOKEN, ROLE, HttpStatus.SC_CREATED);

    // Account作成
    AccountUtils.create(MASTER_TOKEN, CELL_NAME, ACCOUNT, PASSWORD, HttpStatus.SC_CREATED);
    LinksUtils.createLinks(CELL_NAME, Account.EDM_TYPE_NAME, ACCOUNT, null,
            Role.EDM_TYPE_NAME, ROLE, null, MASTER_TOKEN, HttpStatus.SC_NO_CONTENT);
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:25,代碼來源:ServiceSourceAccessControlTest.java

示例9: toReturnValue

import javax.xml.bind.JAXBException; //導入依賴的package包/類
Object toReturnValue(Packet response) {
    try {
        Unmarshaller unmarshaller = jaxbcontext.createUnmarshaller();
        Message msg = response.getMessage();
        switch (mode) {
            case PAYLOAD:
                return msg.<Object>readPayloadAsJAXB(unmarshaller);
            case MESSAGE:
                Source result = msg.readEnvelopeAsSource();
                return unmarshaller.unmarshal(result);
            default:
                throw new WebServiceException("Unrecognized dispatch mode");
        }
    } catch (JAXBException e) {
        throw new WebServiceException(e);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:JAXBDispatch.java

示例10: captureStackTrace

import javax.xml.bind.JAXBException; //導入依賴的package包/類
/**
 * Creates a DOM node that represents the complete stack trace of the exception,
 * and attach that to {@link DetailType}.
 */
final void captureStackTrace(@Nullable Throwable t) {
    if(t==null)     return;
    if(!captureStackTrace)  return;     // feature disabled

    try {
        Document d = DOMUtil.createDom();
        ExceptionBean.marshal(t,d);

        DetailType detail = getDetail();
        if(detail==null)
        setDetail(detail=new DetailType());

        detail.getDetails().add(d.getDocumentElement());
    } catch (JAXBException e) {
        // this should never happen
        logger.log(Level.WARNING, "Unable to capture the stack trace into XML",e);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:SOAPFaultBuilder.java

示例11: setAcl

import javax.xml.bind.JAXBException; //導入依賴的package包/類
/**
 * 親コレクションにwrite権限があるアカウントでファイルの作成を行い201となること.
 * @throws JAXBException ACLのパース失敗
 */
@Test
public void 親コレクションにwrite権限があるアカウントでファイルの作成を行い201となること() throws JAXBException {
    String token;
    String path = String.format("%s/%s", PARENT_COL_NAME, TARGET_SOURCE_FILE_PATH + "new");

    // ACL設定
    setAcl(PARENT_COL_NAME, ROLE, "write");

    // アクセストークン取得
    token = getToken(ACCOUNT);

    // リクエスト実行
    DavResourceUtils.createWebDavFile(token, CELL_NAME, BOX_NAME + "/" + path, "testFileBody",
            MediaType.TEXT_PLAIN, HttpStatus.SC_CREATED);
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:20,代碼來源:ServiceSourceAccessControlTest.java

示例12: getOauthMetadata

import javax.xml.bind.JAXBException; //導入依賴的package包/類
public Metadata getOauthMetadata() throws IOException, JAXBException {
    if (wadlModel == null) {
        throw new IllegalStateException("Should transition state to at least RETRIEVED");
    }
    if (wadlModel.getGrammars() == null || wadlModel.getGrammars().getAny() == null) {
        return null;
    }
    List<Object> otherGrammars = wadlModel.getGrammars().getAny();
    for (Object g : otherGrammars) {
        if (g instanceof Element) {
            Element el = (Element)g;
            if ("http://netbeans.org/ns/oauth/metadata/1".equals(el.getNamespaceURI()) && //NOI18N
                    "metadata".equals(el.getLocalName())) { //NOI18N
                JAXBContext jc = JAXBContext.newInstance("org.netbeans.modules.websvc.saas.model.oauth"); //NOI18N
                Unmarshaller u = jc.createUnmarshaller();
                JAXBElement<Metadata> jaxbEl = u.unmarshal(el, Metadata.class);
                return jaxbEl.getValue();
            }
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:WadlSaas.java

示例13: setAcl

import javax.xml.bind.JAXBException; //導入依賴的package包/類
/**
 * 親コレクションにreadproperties権限がある_かつ_対象ファイルにreadacl権限があるアカウントでファイルのPROPFINDを行い全ての情報が表示されること.
 * @throws JAXBException ACLのパース失敗
 */
@Test
public void 親コレクションにreadproperties権限がある_かつ_対象ファイルにreadacl権限があるアカウントでファイルのPROPFINDを行い全ての情報が表示されること()
        throws JAXBException {
    String token;
    String path = String.format("%s/%s", PARENT_COL_NAME, TARGET_FILE_NAME);
    String pathForPropfind = String.format("%s/%s/%s", BOX_NAME, PARENT_COL_NAME, TARGET_FILE_NAME);

    // ACL設定
    setAcl(PARENT_COL_NAME, ROLE, "read-properties");
    setAcl(path, ROLE, "read-acl");

    // アクセストークン取得
    token = getToken(ACCOUNT);

    // リクエスト実行
    TResponse res = DavResourceUtils.propfind(token, CELL_NAME, pathForPropfind, "1", HttpStatus.SC_MULTI_STATUS);
    String expectedUrl = UrlUtils.box(CELL_NAME, BOX_NAME, path);
    DavResourceUtils.assertContainsHrefUrl(expectedUrl, res);
    DavResourceUtils.assertContainsNodeInResXml(res, "ace");
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:25,代碼來源:FileAccessControlTest.java

示例14: getClickAction

import javax.xml.bind.JAXBException; //導入依賴的package包/類
@Override
public void getClickAction(final Dictionary dictionary, final TabFactory tabFactory, final DialogFactory dialogFactory) {
    EditorTab currTab = ((EditorTab) tabFactory.getSelectedTab());
    try {
        if (currTab.getEditorPane().saveDocx()) {
            dialogFactory.buildConfirmationDialogBox(
                    dictionary.DIALOG_EXPORT_SUCCESS_TITLE,
                    dictionary.DIALOG_EXPORT_SUCCESS_DOCX_CONTENT
            ).showAndWait();
        }
    } catch (Docx4JException | JAXBException e1) {
        dialogFactory.buildExceptionDialogBox(
                dictionary.DIALOG_EXCEPTION_TITLE,
                dictionary.DIALOG_EXCEPTION_EXPORT_DOCX_CONTENT,
                e1.getMessage(),
                e1
        ).showAndWait();
    }
}
 
開發者ID:jdesive,項目名稱:textmd,代碼行數:20,代碼來源:EditorExportDocxItem.java

示例15: readRequest

import javax.xml.bind.JAXBException; //導入依賴的package包/類
public void readRequest(Message msg, Object[] args) throws JAXBException {
    com.sun.xml.internal.ws.api.message.Header header = null;
    Iterator<com.sun.xml.internal.ws.api.message.Header> it =
        msg.getHeaders().getHeaders(headerName,true);
    if (it.hasNext()) {
        header = it.next();
        if (it.hasNext()) {
            throw createDuplicateHeaderException();
        }
    }

    if(header!=null) {
        setter.put( header.readAsJAXB(bridge), args );
    } else {
        // header not found.
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:EndpointArgumentsBuilder.java


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