当前位置: 首页>>代码示例>>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;未经允许,请勿转载。