Example usage for javax.xml.bind JAXBException printStackTrace

List of usage examples for javax.xml.bind JAXBException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this JAXBException and its stack trace (including the stack trace of the linkedException if it is non-null) to System.err .

Usage

From source file:org.jts.docGenerator.indexFiles.AllServiceDefinitions.java

public AllServiceDefinitions(File destDir) {
    this.destDir = destDir;

    try {/* ww w  . ja v a 2 s. c om*/
        JAXBContext jc = JAXBContext.newInstance("org.jts.jsidl.binding");
        unmarshaller = jc.createUnmarshaller();
    } catch (JAXBException je) {
        je.printStackTrace();
    }

    factory = new ObjectFactory();
}

From source file:org.jts.docGenerator.indexFiles.AllServiceSets.java

public AllServiceSets(File destDir) {
    this.destDir = destDir;

    try {//w  w w. j a  v a 2  s  . c  o m
        JAXBContext jc = JAXBContext.newInstance("org.jts.jsidl.binding");
        unmarshaller = jc.createUnmarshaller();
    } catch (JAXBException je) {
        je.printStackTrace();
    }

    factory = new ObjectFactory();
}

From source file:org.jts.docGenerator.indexFiles.AllServiceSets.java

/**
 * Populate a list of links to service sets.
 * @param serviceSetList// w  ww.j  ava 2  s  . c  om
 * @param ssetLinkList
 * @param outputDir
 * @return
 */
private List populateServiceSetList(List<ServiceSet> serviceSetList, List<Item> ssetLinkList, File outputDir) {
    if (ssetLinkList == null || outputDir == null) {
        return null;
    }

    // each service set should have a corresponding directory under the output dir at this point,
    // with each s. set's dir containing an xml file inside named after the service set.
    // for example, service set called "FooSet" will have FooSet/FooSet.xml .
    ArrayList<File> ssetXMLFiles = new ArrayList<File>();

    for (ServiceSet sset : serviceSetList) {
        String ssetName = sset.getName();
        File correspondingXMLFile = new File(outputDir, ssetName + File.separatorChar + ssetName + ".xml");
        if (correspondingXMLFile.isFile()) {
            ssetXMLFiles.add(correspondingXMLFile);
        } else {
            throw new RuntimeException("The XML file for a service set was missing.");
        }
    }

    // sort file list by comparing their filenames.
    Collections.sort(ssetXMLFiles, AllDocGeneratorCommon.FilenameFileComparator.INSTANCE);

    StringBuilder urlBuilder = new StringBuilder();

    // populate service set list from file list
    for (File file : ssetXMLFiles) {
        try {
            InputStream is = IO.getInputStream(file);

            if (is != null) {
                unmarshaller.unmarshal(is);
                is.close();
            }

            // make sure it's an XML file.
            String filePath = file.toString();
            if (!filePath.endsWith(".xml")) {
                throw new RuntimeException("Attempted to process a non-.xml file");
            }

            Item item = factory.createItem();

            // set link text to the name of the file, without extension.
            item.setName(FilenameUtils.getBaseName(filePath));

            // clears the stringbuilder
            urlBuilder.setLength(0);

            // put in part excluding '.xml' and append '.html'.
            urlBuilder.append(filePath.substring(0, filePath.lastIndexOf(".xml")));
            urlBuilder.append(".html");

            String url = URLHelpers.getRelativeURL(urlBuilder, outputDir);
            item.setUrl(url);

            // get the actual description of the service set and set it as the service set item's description
            for (int jj = 0; jj < serviceSetList.size(); jj++) {
                ServiceSet sSet = (ServiceSet) serviceSetList.get(jj);

                if (sSet.getName().equalsIgnoreCase(item.getName())) {
                    item.setDescription(sSet.getDescription().getContent());
                    break;
                }
            }

            item.setTarget(TARGET_FRAME);
            ssetLinkList.add(item);

        } catch (JAXBException je) {
            je.printStackTrace();
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }

    return ssetLinkList;
}

From source file:org.jts.docGenerator.indexFiles.MainMenu.java

public MainMenu() {
    try {//  w ww.  j  a v  a2s. co m
        JAXBContext jc = JAXBContext.newInstance("org.jts.jsidl.binding");
        unmarshaller = jc.createUnmarshaller();
    } catch (JAXBException je) {
        je.printStackTrace();
    }

    factory = new org.jts.docGenerator.indexFiles.binding.ObjectFactory();
}

From source file:org.jts.docGenerator.indexFiles.MainMenu.java

public void build(File path) {
    if (path == null) {
        throw new NullPointerException(" null path found. Cannot create mainMenu.xml");
    }//from   w  ww.  j  a  v  a 2s.c  o  m
    if (!path.isDirectory()) {
        throw new IllegalArgumentException(path + " is not a directory. Cannot create mainMenu.xml");
    }

    destDir = path;

    //System.out.println("Generating mainMenu.xml for "+path+" ...");

    try {
        Index index = factory.createIndex();
        index.setName("Main Menu");
        index.setDescription("");
        List ssList = index.getItem();

        try {
            populateMainMenu(ssList, path);
        } catch (JAXBException je) {
            je.printStackTrace();
        }

        JAXBContext jc = JAXBContext.newInstance("org.jts.docGenerator.indexFiles.binding");
        Marshaller m = jc.createMarshaller();

        // create index xml file to write to
        FileOutputStream fos = new FileOutputStream(path + File.separator + "mainMenu.xml");

        // marshal JAXB index object to xml file
        m.marshal(index, fos);

        fos.flush();

    } catch (Exception je) {
        je.printStackTrace();
    }
}

From source file:org.jts.docGenerator.indexFiles.SubMenuA.java

public SubMenuA() {
    try {/*from   www.j av a 2  s  .com*/
        JAXBContext jc = JAXBContext.newInstance("org.jts.jsidl.binding");
        unmarshaller = jc.createUnmarshaller();
    } catch (JAXBException je) {
        je.printStackTrace();
    }

    factory = new org.jts.docGenerator.indexFiles.binding.ObjectFactory();
}

From source file:org.jts.docGenerator.indexFiles.SubMenuA.java

public void build(File destDir, File path) {
    this.destDir = destDir;

    if (path == null) {
        throw new NullPointerException(" null path found. Cannot create subMenuA.xml");
    }/*from   w w w. ja  v  a2 s . c o  m*/
    if (!path.isDirectory()) {
        throw new IllegalArgumentException(path + " is not a directory. Cannot create subMenuA.xml");
    }

    try {
        Index sdi = factory.createIndex();
        sdi.setName("Sub Menu A");
        String cls = path.toString();

        int loc = cls.lastIndexOf(File.separator) + 1;
        if (cls.equals(destDir.toString())) {
            sdi.setDescription("All");
        } else if (loc > 0 && loc < cls.length()) {
            cls = cls.substring(loc);
            sdi.setDescription(cls);
        } else {
            sdi.setDescription("");
        }
        List sdList = sdi.getItem();

        try {
            populateServiceDefinitionList(sdList, path);
        } catch (JAXBException je) {
            je.printStackTrace();
        }

        JAXBContext jc = JAXBContext.newInstance("org.jts.docGenerator.indexFiles.binding");
        Marshaller m = jc.createMarshaller();

        // create index xml file to write to
        FileOutputStream fos = new FileOutputStream(path + File.separator + "subMenuA.xml");

        // marshal JAXB index object to xml file
        m.marshal(sdi, fos);

        fos.flush();

    } catch (Exception je) {
        je.printStackTrace();
    }
}

From source file:org.jts.docGenerator.indexFiles.SubMenuB.java

public SubMenuB() {
    try {/*from   w  ww .  j av  a  2  s  . c om*/
        JAXBContext jc = JAXBContext.newInstance("org.jts.jsidl.binding");
        unmarshaller = jc.createUnmarshaller();
    } catch (JAXBException je) {
        je.printStackTrace();
    }

    factory = new org.jts.docGenerator.indexFiles.binding.ObjectFactory();
}

From source file:org.jts.docGenerator.indexFiles.SubMenuB.java

public void build(File destDir, File curDir) {
    this.destDir = destDir;

    if (curDir == null) {
        throw new NullPointerException(" null path found. Cannot create subMenuB.xml");
    }// w w  w.  ja v a2s . co m
    if (!curDir.isDirectory()) {
        throw new IllegalArgumentException(curDir + " is not a directory. Cannot create subMenuB.xml");
    }

    try {
        Index mdi = factory.createIndex();
        mdi.setName("Sub Menu B");
        String cls = curDir.toString();

        int loc = cls.lastIndexOf(File.separator) + 1;
        if (cls.equals(destDir.toString())) {
            mdi.setDescription("All");
        } else if (loc > 0 && loc < cls.length()) {
            cls = cls.substring(loc);
            mdi.setDescription(cls);
        } else {
            mdi.setDescription("");
        }
        List mdList = mdi.getItem();

        try {
            populateMessageDefinitionList(mdList, destDir, curDir);
        } catch (JAXBException je) {
            je.printStackTrace();
        }

        JAXBContext jc = JAXBContext.newInstance("org.jts.docGenerator.indexFiles.binding");
        Marshaller m = jc.createMarshaller();

        // create index xml file to write to
        FileOutputStream fos = new FileOutputStream(curDir + File.separator + "subMenuB.xml");

        // marshal JAXB index object to xml file
        m.marshal(mdi, fos);

        fos.flush();

    } catch (Exception je) {
        je.printStackTrace();
    }
}

From source file:org.kalypso.model.wspm.pdb.ui.internal.wspm.InitPerspectiveJob.java

private String createGmvInput() {
    try {/*  ww  w.j  ava 2  s.c om*/
        final IFile modelFile = m_project.getModelFile();
        final URL modelURL = ResourceUtilities.createQuietURL(modelFile);

        final Gistreeview gistreeview = TemplateUtilities.OF_GISTREEVIEW.createGistreeview();
        final LayerType layerType = TemplateUtilities.OF_TEMPLATE_TYPES.createLayerType();

        layerType.setFeatureXPath("id( 'root' )/wspm:waterBodyMember"); // root feature //$NON-NLS-1$
        layerType.setHref(modelURL.toExternalForm());
        layerType.setLinktype("gml"); //$NON-NLS-1$

        gistreeview.setInput(layerType);

        final Marshaller marshaller = TemplateUtilities.createGistreeviewMarshaller(CharEncoding.UTF_8);
        final StringWriter sw = new StringWriter();
        marshaller.marshal(gistreeview, sw);
        sw.close();
        return sw.toString();
    } catch (final JAXBException e) {
        e.printStackTrace();
        return null;
    } catch (final IOException e) {
        e.printStackTrace();
        return null;
    }
}