Example usage for javax.xml.bind DatatypeConverter setDatatypeConverter

List of usage examples for javax.xml.bind DatatypeConverter setDatatypeConverter

Introduction

In this page you can find the example usage for javax.xml.bind DatatypeConverter setDatatypeConverter.

Prototype

public static void setDatatypeConverter(DatatypeConverterInterface converter) 

Source Link

Document

This method is for JAXB provider use only.

Usage

From source file:org.openanzo.rdf.datatype.TypeMaps.java

/**
 * This method should be called the constructor of each type map so that the DatatypeConverter is initialized. It is important to do this in every class
 * since we can't predict which will be loaded first. And the outer class isn't necessarily loaded when a static inner class is loaded. So putting this in
 * the outer class's static initializer isn't enough. See
 */// w  w  w .j a  va2s. com
private static void initializeDatatypeConverter() {
    if (!initialized) {
        DatatypeConverter.setDatatypeConverter(new DatatypeConverterImpl());
        initialized = true;
    }
}

From source file:org.texai.kb.persistence.DistributedRepositoryManager.java

/** Gets the singleton distributed repository manager instance, while performing two phase initialization.
 *
 * @return the singleton distributed repository manager instance
 *///  w w w .j  a va2  s . c  o m
public static synchronized DistributedRepositoryManager getInstance() {
    if (initializationPhase == NOT_INITIALIZED_PHASE) {
        // because the RDF entity manager depends upon an initialized distributed repository manager, it cannot be
        // used to persist or load the repository content description objects
        LOGGER.info("initializing the distributed repository manager using file input");
        synchronized (DISTRIBUTED_REPOSITORY_MANAGER_LOCK) {
            initializationPhase = INITIALIZED_USING_FILE_PHASE;
            assert distributedRepositoryManager == null;
            distributedRepositoryManager = new DistributedRepositoryManager();
            distributedRepositoryManager.initializeUsingFile();
            deleteNamedRepository("RepositoryContentDescriptions");
            RDFEntityManager.setDistributedRepositoryManager(distributedRepositoryManager); // inject dependency

            // conveniently perform other one-time class initializations
            DatatypeConverter.setDatatypeConverter(new DatatypeConverterImpl());
        }
    } else if (initializationPhase == INITIALIZED_USING_FILE_PHASE) {
        // the distributed repository manager has been initialized from a file, so it can be used by the RDF entity
        // manager to persist the repository content descriptions into a repository
        LOGGER.info("initializing the distributed repository manager by persisting its entities");
        synchronized (DISTRIBUTED_REPOSITORY_MANAGER_LOCK) {
            initializationPhase = INITIALIZED_USING_REPOSITORY_PHASE;
            assert distributedRepositoryManager != null;
            distributedRepositoryManager.initializeUsingRepository();
        }
    }

    //Postconditions
    assert distributedRepositoryManager != null : "distributedRepositoryManager must not be null, initializationPhase: "
            + initializationPhase;

    return distributedRepositoryManager;
}

From source file:org.texai.kb.persistence.PersistANewFriendTest.java

@Test
public void test() {
    LOGGER.info("test");
    DistributedRepositoryManager.addTestRepositoryPath(TEST_REPOSITORY_NAME, true); // isRepositoryDirectoryCleaned

    DatatypeConverter.setDatatypeConverter(new DatatypeConverterImpl());
    final PersistANewFriend persistANewFriend = new PersistANewFriend();
    persistANewFriend.initialize();// ww w  .  j a  va  2 s  .c o  m
    persistANewFriend.createAndPersistAFriend();
    persistANewFriend.finalization();
    LOGGER.info("  test OK");
}

From source file:org.texai.kb.persistence.RDFEntityPersisterTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    LOGGER.info("oneTimeSetup");
    CacheInitializer.initializeCaches();
    RDFEntityPersisterTest.class.getClassLoader().setDefaultAssertionStatus(true);
    rdfEntityManager = new RDFEntityManager();
    DatatypeConverter.setDatatypeConverter(new DatatypeConverterImpl());

    DistributedRepositoryManager.addTestRepositoryPath(TEST_REPOSITORY_NAME, true); // isRepositoryDirectoryCleaned

    try {/*from   w  w w  .  ja  v  a2 s.co  m*/
        repositoryConnection = rdfEntityManager.getConnectionToNamedRepository(TEST_REPOSITORY_NAME);
        repositoryConnection.clear();
    } catch (RepositoryException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    Logger.getLogger(RDFEntityPersister.class).setLevel(Level.INFO);
}

From source file:org.texai.kb.persistence.UpdateAFriendTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    CacheInitializer.initializeCaches();
    DatatypeConverter.setDatatypeConverter(new DatatypeConverterImpl());
}

From source file:psidev.psi.mi.xml.io.impl.PsimiXmlWriter253.java

private Marshaller getMarshaller(psidev.psi.mi.xml253.jaxb.EntrySet jEntrySet) throws PsimiXmlWriterException {

    try {// w w w . ja  v  a 2 s .  c o  m
        // create a JAXBContext capable of handling classes generated into the jaxb package
        ClassLoader cl = ObjectFactory.class.getClassLoader();
        JAXBContext jc = JAXBContext
                .newInstance(psidev.psi.mi.xml253.jaxb.EntrySet.class.getPackage().getName(), cl);

        // setup customized converter
        DatatypeConverter.setDatatypeConverter(new PsiJaxbConverter());

        // create and return Unmarshaller
        Marshaller marshaller = jc.createMarshaller();
        // configure marshaller
        marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, calculateSchemaLocation(jEntrySet.getLevel(),
                jEntrySet.getVersion(), jEntrySet.getMinorVersion()));

        return marshaller;
    } catch (Exception e) {
        throw new PsimiXmlWriterException("En error occured while writing EntrySet", e);
    }
}

From source file:psidev.psi.mi.xml.io.impl.PsimiXmlWriter254.java

private Marshaller getMarshaller(psidev.psi.mi.xml254.jaxb.EntrySet jEntrySet) throws PsimiXmlWriterException {

    try {//ww w  .  j  a v a2s .  co m
        // create a JAXBContext capable of handling classes generated into the jaxb package
        ClassLoader cl = ObjectFactory.class.getClassLoader();
        JAXBContext jc = JAXBContext
                .newInstance(psidev.psi.mi.xml254.jaxb.EntrySet.class.getPackage().getName(), cl);

        // setup customized converter
        DatatypeConverter.setDatatypeConverter(new PsiJaxbConverter());

        // create and return Unmarshaller
        Marshaller marshaller = jc.createMarshaller();

        // configure marshaller
        marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, calculateSchemaLocation(jEntrySet.getLevel(),
                jEntrySet.getVersion(), jEntrySet.getMinorVersion()));

        return marshaller;
    } catch (Exception e) {
        throw new PsimiXmlWriterException("En error occured while writing EntrySet", e);
    }
}