Exemplo n.º 1
0
  private void setAttributes(Element classificationElement, Classification classificationObject) {
    /*
     * domain %string; #REQUIRED
     */
    // List<Attribute> attributes = new ArrayList<Attribute>();
    List attributes = new ArrayList();

    attributes.add(new Attribute("domain", classificationObject.getDomain()));

    classificationElement.setAttributes(attributes);
  }
Exemplo n.º 2
0
 @Test
 public void testExecuteThrowsParseException1() throws Throwable {
   Element e = new Element("testBSHMethodName", Namespace.NO_NAMESPACE);
   e.addContent("XXXXXXX XXXXXXXXX XXXX");
   e.setAttributes(new ArrayList());
   try {
     BSHMethod.createBshMethod(e).execute(arguments, "testBSHMethodResultName");
     fail("Expected ParseException to be thrown");
   } catch (ParseException ex) {
     assertThat(ex.getMessage(), allOf(notNullValue(), containsString("line 1, column 19")));
   }
 }
Exemplo n.º 3
0
  private void setAttributes(Element descriptionElement, Description descriptionObject) {
    /*
     * xml:lang %xmlLangCode; #REQUIRED
     */
    // List<Attribute> attributes = new ArrayList<Attribute>();
    List attributes = new ArrayList();

    attributes.add(
        new Attribute(
            "lang",
            descriptionObject.getLang(),
            Namespace.getNamespace("xml", "http://www.w3.org/1999/xhtml")));

    descriptionElement.setAttributes(attributes);
  }
Exemplo n.º 4
0
 @Test
 public void testInitInterpreterThrowsEvalError() throws Throwable {
   Element e = new Element("testBSHMethodName", Namespace.NO_NAMESPACE);
   e.addContent("testBSHMethod\rStr");
   e.setAttributes(new ArrayList());
   BSHMethod bshMethod = BSHMethod.createBshMethod(e);
   try {
     bshMethod.initInterpreter(arguments);
     fail("Expected EvalError to be thrown");
   } catch (EvalError ex) {
     assertEquals(
         "ex.getMessage()",
         "Sourced file: inline evaluation of: ``testBSHMethod Str;'' : Typed variable declaration : Class: testBSHMethod not found in namespace",
         ex.getMessage());
     assertEquals(
         "ex.getMessage()",
         "Sourced file: inline evaluation of: ``testBSHMethod Str;'' : Typed variable declaration : Class: testBSHMethod not found in namespace",
         ex.getMessage());
     assertEquals("(HashMap) arguments.size()", 0, arguments.size());
   }
 }
Exemplo n.º 5
0
  /**
   * Adds attributes from in element to out element.
   *
   * @param out out element
   * @param in in element
   */
  private void addAttributes(Element out, Element in) {

    LinkedHashMap<String, Attribute> allAttributes = new LinkedHashMap<String, Attribute>();

    List<Attribute> outAttributes = new ArrayList<Attribute>(out.getAttributes());
    List<Attribute> inAttributes = new ArrayList<Attribute>(in.getAttributes());

    for (Attribute attr : outAttributes) {
      attr.detach();
      allAttributes.put(attr.getQualifiedName(), attr);
      logger.fine("adding attr from out:" + attr);
    }

    for (Attribute attr : inAttributes) {
      attr.detach();
      allAttributes.put(attr.getQualifiedName(), attr);
      logger.fine("adding attr from in:" + attr);
    }

    out.setAttributes(new ArrayList<Attribute>(allAttributes.values()));
  }