Java Code Examples for org.jdom.JDOMException#printStackTrace()

The following examples show how to use org.jdom.JDOMException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PcodeInjectLibraryJava.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public PcodeInjectLibraryJava(SleighLanguage l) {
	super(l);
	language = l;
	implementedOps = new HashSet<>();
	implementedOps.add(GETFIELD);
	implementedOps.add(GETSTATIC);
	implementedOps.add(INVOKE_DYNAMIC);
	implementedOps.add(INVOKE_INTERFACE);
	implementedOps.add(INVOKE_SPECIAL);
	implementedOps.add(INVOKE_STATIC);
	implementedOps.add(INVOKE_VIRTUAL);
	implementedOps.add(LDC);
	implementedOps.add(LDC2_W);
	implementedOps.add(LDC_W);
	implementedOps.add(MULTIANEWARRAY);
	implementedOps.add(PUTFIELD);
	implementedOps.add(PUTSTATIC);

	String translateSpec = language.buildTranslatorTag(language.getAddressFactory(),
		getUniqueBase(), language.getSymbolTable());

	paramPayload = null;
	parser = null;
	try {
		parser = new PcodeParser(translateSpec);
	}
	catch (JDOMException e1) {
		e1.printStackTrace();
	}
}
 
Example 2
Source File: CreoleRegisterImpl.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Parse a directory file (represented as an open stream), adding resource
 * data objects to the CREOLE register as they occur. If the resource is from
 * a URL then that location is passed (otherwise null).
 */
protected void parseDirectory(Plugin plugin, Document jdomDoc,
    URL directoryUrl, URL creoleFileUrl) throws GateException {
  // create a handler for the directory file and parse it;
  // this will create ResourceData entries in the register
  try {

    CreoleAnnotationHandler annotationHandler =
        new CreoleAnnotationHandler(plugin);

    GateClassLoader gcl = Gate.getClassLoader()
        .getDisposableClassLoader(plugin.getBaseURI().toString());

    // Add any JARs from the creole.xml to the GATE ClassLoader
    annotationHandler.addJarsToClassLoader(gcl, jdomDoc);

    // Make sure there is a RESOURCE element for every resource type the
    // directory defines
    annotationHandler.createResourceElementsForDirInfo(jdomDoc);

    processFullCreoleXmlTree(plugin, jdomDoc,
        annotationHandler);
  } catch(URISyntaxException | IOException e) {
    throw (new GateException(e));
  } catch(JDOMException je) {
    if(DEBUG) je.printStackTrace(Err.getPrintWriter());
    throw (new GateException(je));
  }

}
 
Example 3
Source File: UTransferRequestElement.java    From axelor-open-suite with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void buildTransfer() throws AxelorException {
  EbicsRequest request;
  Header header;
  Body body;
  MutableHeaderType mutable;
  SegmentNumber segmentNumber;
  StaticHeaderType xstatic;
  OrderData orderData;
  DataTransferRequestType dataTransfer;

  segmentNumber = EbicsXmlFactory.createSegmentNumber(this.segmentNumber, lastSegment);
  mutable = EbicsXmlFactory.createMutableHeaderType("Transfer", segmentNumber);
  xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), transactionId);
  header = EbicsXmlFactory.createEbicsRequestHeader(true, mutable, xstatic);
  orderData = EbicsXmlFactory.createEbicsRequestOrderData(IOUtils.getFactoryContent(content));
  dataTransfer = EbicsXmlFactory.createDataTransferRequestType(orderData);
  body = EbicsXmlFactory.createEbicsRequestBody(dataTransfer); // TODO CHECK
  request = EbicsXmlFactory.createEbicsRequest(1, "H003", header, body);
  document = EbicsXmlFactory.createEbicsRequestDocument(request);

  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  try {
    this.save(bout);
  } catch (JDOMException e) {
    // TODO Bloc catch généré automatiquement
    e.printStackTrace();
  }

  System.out.println(
      "Requete data ----------------------------------------------------------------------------");
  System.out.println(bout.toString());
}
 
Example 4
Source File: ModifyXMLFile.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	try {

		SAXBuilder builder = new SAXBuilder();

		Document doc = (Document) builder.build(ClassLoader
				.getSystemResource("file.xml"));
		Element rootNode = doc.getRootElement();

		// update staff id attribute
		Element staff = rootNode.getChild("staff");
		staff.getAttribute("id").setValue("2");

		// add new age element
		Element age = new Element("age").setText("28");
		staff.addContent(age);

		// update salary value
		staff.getChild("salary").setText("7000");

		// remove firstname element
		staff.removeChild("firstname");

		XMLOutputter xmlOutput = new XMLOutputter();

		// display nice nice
		xmlOutput.setFormat(Format.getPrettyFormat());
		xmlOutput.output(doc, new FileWriter("target/file.xml"));

		// xmlOutput.output(doc, System.out);

		System.out.println("File updated!");
	} catch (IOException io) {
		io.printStackTrace();
	} catch (JDOMException e) {
		e.printStackTrace();
	}
}
 
Example 5
Source File: BeautiFrame.java    From beast-mcmc with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void importFiles(File[] files) {
        for (File file : files) {
            if (file == null || file.getName().equals("")) {
                JOptionPane.showMessageDialog(this, "Invalid file name",
                        "Invalid file name", JOptionPane.ERROR_MESSAGE);
            } else {
                try {
                    BEAUTiImporter beautiImporter = new BEAUTiImporter(this, options);
                    beautiImporter.importFromFile(file);

                    setDirty();
//                    } catch (FileNotFoundException fnfe) {
//                        JOptionPane.showMessageDialog(this, "Unable to open file: File not found",
//                                "Unable to open file", JOptionPane.ERROR_MESSAGE);
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(this, "File I/O Error unable to read file: " + ioe.getMessage(),
                            "Unable to read file", JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                    // there may be other files in the list so don't return
//                    return;

                } catch (MissingBlockException ex) {
                    JOptionPane.showMessageDialog(this, "TAXON, DATA or CHARACTERS block is missing in Nexus file: " + ex,
                            "Missing Block in Nexus File",
                            JOptionPane.ERROR_MESSAGE);
                    ex.printStackTrace();

                } catch (ImportException ime) {
                    JOptionPane.showMessageDialog(this, "Error parsing imported file: " + ime,
                            "Error reading file",
                            JOptionPane.ERROR_MESSAGE);
                    ime.printStackTrace();
                } catch (JDOMException jde) {
                    JOptionPane.showMessageDialog(this, "Error parsing imported file: " + jde,
                            "Error reading file",
                            JOptionPane.ERROR_MESSAGE);
                    jde.printStackTrace();
                }
            }
        }

        if (!options.hasIdenticalTaxa()) {
            setAllOptions(); // need this to refresh panels otherwise it will throw exception
            dataPanel.selectAll();
            dataPanel.unlinkTreeModels();
        }

        setAllOptions();

    }
 
Example 6
Source File: FileTransfer.java    From axelor-open-suite with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Initiates a file transfer to the bank.
 *
 * @param content The bytes you want to send.
 * @param orderType As which order type
 * @throws IOException
 * @throws EbicsException
 */
public void sendFile(byte[] content, OrderType orderType, byte[] signature)
    throws IOException, AxelorException {
  HttpRequestSender sender;
  UInitializationRequestElement initializer;
  InitializationResponseElement response;
  int httpCode;
  EbicsTransferState state;

  sender = new HttpRequestSender(session);

  initializer = new UInitializationRequestElement(session, orderType, content, signature);

  initializer.build();

  initializer.validate();
  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  try {
    initializer.save(bout);
  } catch (JDOMException e) {
    // TODO Bloc catch généré automatiquement
    e.printStackTrace();
  }
  System.out.println(
      "Requete ----------------------------------------------------------------------------");
  System.out.println(bout.toString());

  httpCode = sender.send(new ByteArrayContentFactory(initializer.prettyPrint()));

  EbicsUtils.checkHttpCode(httpCode);
  response =
      new InitializationResponseElement(
          sender.getResponseBody(),
          orderType,
          DefaultEbicsRootElement.generateName(orderType),
          session.getUser());
  response.build();
  response.report(new EbicsRootElement[] {initializer, response});
  state = new EbicsTransferState();
  state.setNumSegments(initializer.getSegmentNumber());
  state.setTransactionId(response.getTransactionId());
  int segNumber = 1;
  while (segNumber <= state.getNumSegments()) {
    state.setSegmentNumber(segNumber);
    if (segNumber == state.getSegmentNumber()) {
      state.setLastSegment(true);
    }
    sendFile(
        initializer.getContent(segNumber),
        segNumber,
        state.getLastSegment(),
        state.getTransactionId(),
        orderType);
    segNumber++;
  }
}