private org.jdom2.Element getDataforCase(String specName, String caseID, String data) {
    String caseData = "";
    try {
      caseData = _ibClient.getCaseData(caseID, _handle);
    } catch (IOException e) {
      e.printStackTrace();
    }
    org.jdom2.Element result = new org.jdom2.Element(specName);

    SAXBuilder builder = new SAXBuilder();
    org.jdom2.Element root = null;
    List<org.jdom2.Element> ls = null;
    try {
      org.jdom2.Document document = builder.build(new StringReader(data));
      root = document.getRootElement();

      ls = document.getRootElement().getChildren();
    } catch (Exception e) {
      System.out.println(e);
    }
    for (org.jdom2.Element l : ls) {
      String paramName = l.getName();
      org.jdom2.Element advElem = root.getChild(paramName);
      try {
        if (advElem != null) {
          org.jdom2.Element copy = (org.jdom2.Element) advElem.clone();
          result.addContent(copy);
        } else {
          result.addContent(new org.jdom2.Element(paramName));
        }
      } catch (IllegalAddException iae) {
      }
    }
    return result;
  }
Exemplo n.º 2
0
 @Test
 public void testOutputEscapedMixedMultiText() {
   // this test has mixed content (text-type and not text type).
   // and, it has a multi-text-type at the end.
   Element root = new Element("root");
   root.addContent(new Comment("Boo"));
   root.addContent(new Text(" xx "));
   root.addContent(new Text("<emb>"));
   root.addContent(new Text(" xx "));
   FormatSetup fs =
       new FormatSetup() {
         @Override
         public void setup(Format fmt) {
           fmt.setExpandEmptyElements(true);
         }
       };
   checkOutput(
       root,
       fs,
       "<root><!--Boo--> xx &lt;emb&gt; xx </root>",
       "<root><!--Boo-->xx &lt;emb&gt; xx</root>",
       "<root>\n  <!--Boo-->\n  xx &lt;emb&gt; xx\n</root>",
       "<root>\n  <!--Boo-->\n  xx &lt;emb&gt; xx\n</root>",
       "<root>\n  <!--Boo-->\n   xx &lt;emb&gt; xx \n</root>");
 }
Exemplo n.º 3
0
  protected Element genCoverageOfferingBriefElem(
      String elemName,
      String covName,
      String covLabel,
      String covDescription,
      GridCoordSystem gridCoordSys) {

    // <CoverageOfferingBrief>
    Element briefElem = new Element(elemName, wcsNS);

    // <CoverageOfferingBrief>/gml:metaDataProperty [0..*]
    // <CoverageOfferingBrief>/gml:description [0..1]
    // <CoverageOfferingBrief>/gml:name [0..*]
    // <CoverageOfferingBrief>/metadataLink [0..*]

    // <CoverageOfferingBrief>/description [0..1]
    // <CoverageOfferingBrief>/name [1]
    // <CoverageOfferingBrief>/label [1]
    if (covDescription != null && !covDescription.equals(""))
      briefElem.addContent(new Element("description", wcsNS).addContent(covDescription));
    briefElem.addContent(new Element("name", wcsNS).addContent(covName));
    briefElem.addContent(new Element("label", wcsNS).addContent(covLabel));

    // <CoverageOfferingBrief>/lonLatEnvelope [1]
    briefElem.addContent(genLonLatEnvelope(gridCoordSys));

    // ToDo Add keywords capabilities.
    // <CoverageOfferingBrief>/keywords [0..*]  /keywords [1..*] and /type [0..1]

    return briefElem;
  }
Exemplo n.º 4
0
  @Test
  public void testChangeMainWithOthers() {
    Namespace nsa = Namespace.getNamespace("pfxa", "nsurla");
    Namespace nsb = Namespace.getNamespace("pfxb", "nsurlb");
    Namespace nsc = Namespace.getNamespace("pfxc", "nsurlc");
    Namespace nsd = Namespace.getNamespace("pfxd", "nsurld");

    Element root = new Element("root", Namespace.getNamespace("rooturl"));
    // child is in a different namespace but with same "" prefix.
    Element child = new Element("child", Namespace.getNamespace("childurl"));
    // leaf is in the NO_NAMESPACE namespace (also prefix "");
    Element leaf = new Element("leaf");

    root.addNamespaceDeclaration(nsa);
    root.addNamespaceDeclaration(nsb);
    root.addNamespaceDeclaration(nsc);
    root.addNamespaceDeclaration(nsd);

    child.addNamespaceDeclaration(nsa);
    child.addNamespaceDeclaration(nsb);
    child.addNamespaceDeclaration(nsc);
    child.addNamespaceDeclaration(nsd);

    // On the leaf we try the varaint of adding the namespace
    // via the attributes.
    leaf.setAttribute("att", "val", nsa);
    leaf.setAttribute("att", "val", nsb);
    leaf.setAttribute("att", "val", nsc);
    leaf.setAttribute("att", "val", nsd);

    root.addContent(child);
    child.addContent(leaf);
    exercise(root, new NamespaceStack());
  }
Exemplo n.º 5
0
  /**
   * This will convert a single property and its value to an XML element and textual value.
   *
   * @param root JDOM root <code>Element</code> to add children to.
   * @param propertyName name to base element creation on.
   * @param propertyValue value to use for property.
   */
  private void createXMLRepresentation(Element root, String propertyName, String propertyValue) {

    int split;
    String name = propertyName;
    Element current = root;
    Element test = null;

    while ((split = name.indexOf(".")) != -1) {
      String subName = name.substring(0, split);
      name = name.substring(split + 1);

      // Check for existing element
      if ((test = current.getChild(subName)) == null) {
        Element subElement = new Element(subName);
        current.addContent(subElement);
        current = subElement;
      } else {
        current = test;
      }
    }

    // When out of loop, what's left is the final element's name
    Element last = new Element(name);
    last.setText(propertyValue);
    // Attribute attribute = new Attribute("value", propertyValue);
    // last.setAttribute(attribute);
    current.addContent(last);
  }
Exemplo n.º 6
0
  @Test
  public void testChangeAltWithOthers() {
    // note, they all have same prefix.
    Namespace nsa = Namespace.getNamespace("pfxa", "nsurla");
    Namespace nsb = Namespace.getNamespace("pfxa", "nsurlb");
    Namespace nsc = Namespace.getNamespace("pfxa", "nsurlc");
    Namespace alta = Namespace.getNamespace("alta", "nsalturla");
    Namespace altb = Namespace.getNamespace("altb", "nsalturlb");

    Element root = new Element("root");
    Element child = new Element("child");
    Element leaf = new Element("leaf");

    root.addNamespaceDeclaration(nsa);
    root.addNamespaceDeclaration(alta);
    root.addNamespaceDeclaration(altb);

    child.addNamespaceDeclaration(nsb);
    child.addNamespaceDeclaration(alta);
    child.addNamespaceDeclaration(altb);

    // On the leaf we try the varaint of adding the namespace
    // via the attributes.
    leaf.setAttribute("att", "val", nsc);
    leaf.addNamespaceDeclaration(alta);
    leaf.addNamespaceDeclaration(altb);

    root.addContent(child);
    child.addContent(leaf);
    exercise(root, new NamespaceStack());
  }
Exemplo n.º 7
0
  /**
   * Default implementation for storing the contents of a TurnoutIcon
   *
   * @param o Object to store, of type TurnoutIcon
   * @return Element containing the complete info
   */
  public Element store(Object o) {

    TurnoutIcon p = (TurnoutIcon) o;
    if (!p.isActive()) {
      return null; // if flagged as inactive, don't store
    }
    Element element = new Element("turnouticon");
    element.setAttribute("turnout", p.getNamedTurnout().getName());
    storeCommonAttributes(p, element);

    element.setAttribute("tristate", p.getTristate() ? "true" : "false");
    element.setAttribute("momentary", p.getMomentary() ? "true" : "false");
    element.setAttribute("directControl", p.getDirectControl() ? "true" : "false");

    Element elem = new Element("icons");
    elem.addContent(storeIcon("closed", p.getIcon("TurnoutStateClosed")));
    elem.addContent(storeIcon("thrown", p.getIcon("TurnoutStateThrown")));
    elem.addContent(storeIcon("unknown", p.getIcon("BeanStateUnknown")));
    elem.addContent(storeIcon("inconsistent", p.getIcon("BeanStateInconsistent")));
    element.addContent(elem);
    elem = new Element("iconmaps");
    String family = p.getFamily();
    if (family != null) {
      elem.setAttribute("family", family);
    }
    element.addContent(elem);

    element.setAttribute("class", "jmri.jmrit.display.configurexml.TurnoutIconXml");

    return element;
  }
  private Element crearEstructuraXML() {

    Element historialNotas = new Element(ConstantesArchivosXML.SUPERPADRE);
    Query q = entityManager.createQuery(ConsultasJpql.HISTORIAL_NOTAS_ESTUDIANTES);
    @SuppressWarnings("unchecked")
    List<Usuario> usuarios = (List<Usuario>) q.getResultList();
    for (Usuario usuario : usuarios) {
      Element usuarioXML = crearXMLUsuario(usuario);
      Query q2 = entityManager.createQuery(ConsultasJpql.HISTORIAL_NOTAS);
      q2.setParameter("parametro", usuario.getId());
      @SuppressWarnings("unchecked")
      List<HistorialNotas> notasCurso = (List<HistorialNotas>) q2.getResultList();
      for (HistorialNotas curso : notasCurso) {
        Element cursoXML =
            crearXMLCurso(
                curso.getGrupoCurso().getCursoGrupo(),
                curso.getNota(),
                curso.getGrupoCurso().getIdGrupo(),
                curso.getGrupoCurso().getSemestre());
        usuarioXML.addContent(cursoXML);
      }
      historialNotas.addContent(usuarioXML);
    }
    return historialNotas;
  }
Exemplo n.º 9
0
  public Element toXML() {
    Element result = new Element("timer");

    XMLUtil.createElement("title", getTitle(), result);
    XMLUtil.createElement("started", started == null ? "" : started.toString(), result);
    XMLUtil.createElement("total", period.toString(), result);
    XMLUtil.createElement("speed", update_speed, result);

    XMLUtil.createElement("x", getX(), result);
    XMLUtil.createElement("y", getY(), result);
    XMLUtil.createElement("width", getWidth(), result);
    XMLUtil.createElement("height", getHeight(), result);

    XMLUtil.createElement(
        "foreground", String.format("%08x", total.getForeground().getRGB()), result);
    XMLUtil.createElement(
        "background", String.format("%08x", panel.getBackground().getRGB()), result);

    XMLUtil.createElement("visible", isVisible(), result);

    Element times = new Element("times");
    for (TimeSpan ts : this.times) {
      times.addContent(ts.toXML());
    }
    result.addContent(times);
    return result;
  }
Exemplo n.º 10
0
 private ArrayList<Element> serializeFields(
     Field[] fields, Object object, Document doc) // serializes the fields
     {
   Class currentClass = object.getClass();
   ArrayList<Element> elements = new ArrayList<Element>();
   for (Field f : fields) {
     try {
       if (!f.getType().isPrimitive()) // Field not primitive, is a reference to another object
       {
       } else // field is primitive
       {
         Element newField = new Element("field");
         newField.setAttribute("name", f.getName());
         newField.setAttribute("declaringclass", f.getDeclaringClass().getName());
         Element newValue = new Element("value");
         newValue.addContent(f.get(object).toString());
         newField.addContent(newValue);
         elements.add(newField);
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   return elements;
 }
Exemplo n.º 11
0
  @Override
  public Element getXml() {
    Element me = new Element("sound");
    Integer i;

    log.debug("Configurable Sound:");
    log.debug("  name = " + this.getName());
    log.debug("  start_file = " + start_file);
    log.debug("  mid_file = " + mid_file);
    log.debug("  end_file = " + end_file);
    log.debug("  short_file = " + short_file);
    log.debug("  use_start_file = " + start_file);

    me.setAttribute("name", this.getName());
    me.setAttribute("type", "configurable");
    if (use_start_sound) {
      me.addContent(new Element("start-file").addContent(start_file));
    }
    if (use_mid_sound) {
      me.addContent(new Element("mid-file").addContent(mid_file));
    }
    if (use_end_sound) {
      me.addContent(new Element("end-file").addContent(end_file));
    }
    if (use_short_sound) {
      me.addContent(new Element("short-file").addContent(short_file));
    }
    i = start_sound_duration;
    log.debug("  duration = " + i.toString());
    me.addContent(new Element("start-sound-duration").addContent(i.toString()));

    return (me);
  }
  private String mapItemParamsToAdviceCaseParams(
      String adviceName, List<YParameter> inAspectParams, String data) {
    org.jdom2.Element result = new org.jdom2.Element(adviceName);

    SAXBuilder builder = new SAXBuilder();
    org.jdom2.Element root = null;
    try {
      org.jdom2.Document document = builder.build(new StringReader(data));
      root = document.getRootElement();
    } catch (Exception e) {
      System.out.println(e);
    }
    for (YParameter param : inAspectParams) {
      String paramName = param.getName();
      org.jdom2.Element advElem = root.getChild(paramName);
      try {
        if (advElem != null) {
          org.jdom2.Element copy = (org.jdom2.Element) advElem.clone();
          result.addContent(copy);
        } else {
          result.addContent(new org.jdom2.Element(paramName));
        }
      } catch (IllegalAddException iae) {
        System.out.println("+++++++++++++++++ error:" + iae.getMessage());
      }
    }
    return JDOMUtil.elementToString(result);
  }
Exemplo n.º 13
0
  private String paymentsXml(Pair<QueryResult, Long> queryResult) {
    Element rootElement = new Element("payments");
    rootElement.setAttribute("count", queryResult.snd.toString());
    for (Map<String, Object> record : queryResult.fst) {
      Element affiliateElement =
          new Element("affiliate")
              .setAttribute("id", record.get("affiliate_id").toString())
              .addContent(element("email", record.get("affiliate_email")))
              .addContent(element("wmr", record.get("affiliate_wmr")));

      Element paymentElement =
          new Element("payment")
              .addContent(affiliateElement)
              .addContent(element("basis", record.get("basis")))
              .addContent(element("amount", record.get("amount")))
              .addContent(element("pay-method", record.get("pay_method")));

      if (record.get("offer_id") != null) {
        Element offerElement =
            new Element("offer")
                .setAttribute("id", record.get("offer_id").toString())
                .addContent(element("name", record.get("offer_name")));
        paymentElement.addContent(offerElement);
      }

      rootElement.addContent(paymentElement);
    }
    return OUTPUTTER.outputString(rootElement);
  }
Exemplo n.º 14
0
 /**
  * Appends the log content to the document.
  *
  * @param log the log content, as a String.
  */
 public void appendLog(final String log) {
   if (null != log) {
     final Element logElement = new Element(LOG_ELEMENT_KEY);
     logElement.addContent(log);
     root.addContent(logElement);
     logger.log("  Added log.\n");
   }
 }
Exemplo n.º 15
0
 public Element handleShortAddressVal(Element type, long cv, String name, String comment) {
   Element r = new Element("int");
   r.setAttribute("origin", "" + (4278190080L + cv));
   r.addContent(new Element("name").addContent(name));
   if (comment != null && !comment.equals(""))
     r.addContent(new Element("description").addContent(comment));
   return r;
 }
Exemplo n.º 16
0
 /**
  * {@inheritDoc}
  *
  * @author holdawscot
  */
 @Override
 public Element toXML() {
   Element monster = super.toXML();
   monster.addContent(new Element("deadlyWeapon").setText(this.deadlyWeapon.getID()));
   monster.addContent(new Element("soundEffect").setText(this.soundEffect));
   monster.addContent(new Element("killMessage").setText(this.killMessage));
   return monster;
 }
  @Test
  public void testNormalOperations() throws Exception {
    FedoraObjectUIPProcessor processor = new FedoraObjectUIPProcessor();
    AccessControlService aclService = mock(AccessControlService.class);
    when(aclService.hasAccess(
            any(PID.class), any(AccessGroupSet.class), eq(Permission.editAccessControl)))
        .thenReturn(true);
    processor.setAclService(aclService);

    InputStream entryPart =
        new FileInputStream(new File("src/test/resources/atompub/metadataUnpublish.xml"));
    Abdera abdera = new Abdera();
    Parser parser = abdera.getParser();
    Document<Entry> entryDoc = parser.parse(entryPart);
    Entry entry = entryDoc.getRoot();
    Map<String, org.jdom2.Element> originalMap = new HashMap<String, org.jdom2.Element>();
    org.jdom2.Element rdfElement = new org.jdom2.Element("RDF", JDOMNamespaceUtil.RDF_NS);
    org.jdom2.Element descElement = new org.jdom2.Element("Description", JDOMNamespaceUtil.RDF_NS);
    rdfElement.addContent(descElement);
    org.jdom2.Element relElement =
        new org.jdom2.Element(
            ContentModelHelper.CDRProperty.isPublished.getPredicate(), JDOMNamespaceUtil.CDR_NS);
    relElement.setText("yes");
    descElement.addContent(relElement);
    relElement =
        new org.jdom2.Element(
            ContentModelHelper.CDRProperty.embargoUntil.getPredicate(),
            JDOMNamespaceUtil.CDR_ACL_NS);
    relElement.setText("2013-02-01");
    descElement.addContent(relElement);
    relElement =
        new org.jdom2.Element(
            ContentModelHelper.FedoraProperty.hasModel.name(), JDOMNamespaceUtil.FEDORA_MODEL_NS);
    relElement.setText(ContentModelHelper.Model.SIMPLE.name());
    descElement.addContent(relElement);

    originalMap.put(ContentModelHelper.Datastream.RELS_EXT.getName(), rdfElement);
    Map<String, org.jdom2.Element> datastreamMap =
        AtomPubMetadataParserUtil.extractDatastreams(entry);

    MetadataUIP uip = mock(MetadataUIP.class);
    when(uip.getPID()).thenReturn(new PID("uuid:test/ACL"));
    when(uip.getOperation()).thenReturn(UpdateOperation.REPLACE);
    when(uip.getOriginalData()).thenReturn(originalMap);
    when(uip.getModifiedData()).thenReturn(originalMap);
    when(uip.getIncomingData()).thenReturn(datastreamMap);
    when(uip.getModifiedFiles()).thenReturn(getModifiedFiles(originalMap));

    UIPUpdatePipeline pipeline = mock(UIPUpdatePipeline.class);
    when(pipeline.processUIP(any(UpdateInformationPackage.class))).thenReturn(uip);
    processor.setPipeline(pipeline);
    processor.setVirtualDatastreamMap(new HashMap<String, Datastream>());
    DigitalObjectManager digitalObjectManager = mock(DigitalObjectManager.class);
    processor.setDigitalObjectManager(digitalObjectManager);
    processor.setOperationsMessageSender(mock(OperationsMessageSender.class));

    processor.process(uip);
  }
Exemplo n.º 18
0
 /**
  * Create an XML element to represent this Entry. This member has to remain synchronized with the
  * detailed DTD in operations-trains.dtd.
  */
 public void store(Element root) {
   Element values = new Element(Xml.SCHEDULES);
   // add entries
   List<TrainSchedule> schedules = getSchedulesByIdList();
   for (TrainSchedule schedule : schedules) {
     values.addContent(schedule.store());
   }
   root.addContent(values);
 }
 private static void addTableRow(final Element table, final String[] cells) {
   final Element tr = new Element("tr");
   table.addContent(tr);
   for (final String columnName : cells) {
     final Element td = new Element("td");
     tr.addContent(td);
     td.setText(columnName);
   }
 }
Exemplo n.º 20
0
 protected void write(Transcript transcript, OutputStream out) throws IOException {
   Element root = new Element("transcript");
   root.setAttribute("id", transcript.getId());
   root.addContent(makeElement("location", String.valueOf(transcript.getTimeStamp().getTime())));
   root.addContent(makeElement("location", transcript.getLocation()));
   root.addContent(makeElement("session", String.valueOf(transcript.getSession())));
   root.addContent(makeElement("text", new CDATA(transcript.getTranscriptText())));
   write(root, out);
 }
Exemplo n.º 21
0
 private Element writeJoinArray(JoinArray join) {
   Element joinElem = new Element("join");
   joinElem.setAttribute("class", join.getClass().toString());
   if (join.type != null) joinElem.setAttribute("type", join.type.toString());
   if (join.v != null)
     joinElem.addContent(new Element("variable").addContent(join.v.getFullName()));
   joinElem.addContent(new Element("param").addContent(Integer.toString(join.param)));
   return joinElem;
 }
Exemplo n.º 22
0
 private Element writeJoinMuiltdimStructure(JoinMuiltdimStructure join) {
   Element joinElem = new Element("join");
   joinElem.setAttribute("class", join.getClass().toString());
   if (join.parentStructure != null)
     joinElem.addContent(
         new Element("parentStructure").addContent(join.parentStructure.getFullName()));
   joinElem.addContent(
       new Element("dimLength").setAttribute("value", Integer.toString(join.dimLength)));
   return joinElem;
 }
Exemplo n.º 23
0
 protected void saveSettings(final String xmlFilename) throws IOException {
   final Element root = new Element("Settings");
   root.addContent(viewer.stateToXml());
   root.addContent(setupAssignments.toXml());
   root.addContent(manualTransformation.toXml());
   root.addContent(bookmarks.toXml());
   final Document doc = new Document(root);
   final XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
   xout.output(doc, new FileWriter(xmlFilename));
 }
Exemplo n.º 24
0
 protected Element makeElement(String tag, CalendarEntry value) {
   Element root = new Element(tag);
   if (value != null) {
     root.setAttribute("no", value.getNo());
     root.addContent(makeShortElement("bill", value.getBill()));
     root.addContent(makeShortElement("subBill", value.getBill()));
     root.addContent(makeElement("billHigh", value.getBillHigh()));
   }
   return root;
 }
Exemplo n.º 25
0
 private void addCoord(
     Element tableElem, TableConfig table, Table.CoordName type, List<String> varNames) {
   String name = table.findCoordinateVariableName(type);
   if (name != null) {
     Element elem = new Element("coordinate").setAttribute("type", type.name());
     elem.addContent(name);
     tableElem.addContent(elem);
     varNames.remove(name);
   }
 }
Exemplo n.º 26
0
 private Element writeJoinParentIndex(JoinParentIndex join) {
   Element joinElem = new Element("join");
   joinElem.setAttribute("class", join.getClass().toString());
   if (join.parentStructure != null)
     joinElem.addContent(
         new Element("parentStructure").addContent(join.parentStructure.getFullName()));
   if (join.parentIndex != null)
     joinElem.addContent(new Element("parentIndex").addContent(join.parentIndex));
   return joinElem;
 }
Exemplo n.º 27
0
  private Element crearXMLUsuario(Usuario usuario) {
    Element element = new Element(ConstantesArchivosXML.PADRE);
    element.addContent(new Element(ConstantesArchivosXML.PADREID).setText(usuario.getId() + ""));
    element.addContent(
        new Element(ConstantesArchivosXML.PADREAPELLIDO).setText(usuario.getApellidos()));
    element.addContent(
        new Element(ConstantesArchivosXML.PADREPRIMERNOMBRE).setText(usuario.getPrimerNombre()));
    element.addContent(
        new Element(ConstantesArchivosXML.PADRESEGUNDONOMBRE).setText(usuario.getSegundoNombre()));
    element.addContent(
        new Element(ConstantesArchivosXML.PADRETIPOIDENTIFICACION)
            .setText(usuario.getTipo().getNombre()));
    element.addContent(
        new Element(ConstantesArchivosXML.PADRECODIGO).setText(usuario.getCodigoUsuarios()));
    element.addContent(
        new Element(ConstantesArchivosXML.PADRECORREO).setText(usuario.getCorreoElectronico()));
    element.addContent(
        new Element(ConstantesArchivosXML.PADREESCUELA)
            .setText(usuario.getEnteUniversitarios().getNombreEnteUniversitario()));
    element.addContent(
        new Element(ConstantesArchivosXML.PADREIDENTIFICACION)
            .setText(usuario.getDocumentoIdentidad() + ""));

    return element;
  }
Exemplo n.º 28
0
  /**
   * Store the contents of a OBlockManager.
   *
   * @param o Object to store, of type BlockManager
   * @return Element containing the complete info
   */
  public Element store(Object o) {
    Element blocks = new Element("oblocks");
    blocks.setAttribute("class", "jmri.jmrit.logix.configurexml.OBlockManagerXml");
    OBlockManager manager = (OBlockManager) o;
    Iterator<String> iter = manager.getSystemNameList().iterator();
    while (iter.hasNext()) {
      String sname = iter.next();
      OBlock block = manager.getBySystemName(sname);
      String uname = block.getUserName();
      if (log.isDebugEnabled()) {
        log.debug("OBlock: sysName= " + sname + ", userName= "******"oblock");
      elem.setAttribute("systemName", sname);
      if (uname != null && uname.length() > 0) {
        elem.setAttribute("userName", uname); // doing this for compatibility during 2.9.* series
        elem.addContent(new Element("userName").addContent(uname));
      }
      String comment = block.getComment();
      if (comment != null) {
        Element c = new Element("comment");
        c.addContent(comment);
        elem.addContent(c);
      }
      elem.setAttribute("length", "" + block.getLengthMm());
      elem.setAttribute("units", block.isMetric() ? "true" : "false");
      elem.setAttribute("curve", "" + block.getCurvature());
      if (block.getNamedSensor() != null) {
        Element se = new Element("sensor");
        se.setAttribute("systemName", block.getNamedSensor().getName());
        elem.addContent(se);
      }
      if (block.getNamedErrorSensor() != null) {
        Element se = new Element("errorSensor");
        se.setAttribute("systemName", block.getNamedErrorSensor().getName());
        elem.addContent(se);
      }
      if (block.getReporter() != null) {
        Element se = new Element("reporter");
        se.setAttribute("systemName", block.getReporter().getSystemName());
        se.setAttribute("reportCurrent", block.isReportingCurrent() ? "true" : "false");
        elem.addContent(se);
      }
      elem.setAttribute("permissive", block.getPermissiveWorking() ? "true" : "false");
      elem.setAttribute("speedNotch", block.getBlockSpeed());

      List<Path> paths = block.getPaths();
      for (int j = 0; j < paths.size(); j++) {
        elem.addContent(storePath((OPath) paths.get(j)));
      }
      List<Portal> portals = block.getPortals();
      for (int i = 0; i < portals.size(); i++) {
        elem.addContent(storePortal(portals.get(i)));
      }
      // and put this element out
      blocks.addContent(elem);
    }

    return blocks;
  }
Exemplo n.º 29
0
 @Test
 public void testOutputElementMultiMostWhiteExpandEmpty() {
   // this test has mixed content (text-type and not text type).
   // and, it has a multi-text-type at the end.
   Element root = new Element("root");
   root.addContent(new CDATA(" "));
   root.addContent(new Text(" "));
   root.addContent(new Text("    "));
   root.addContent(new Text(""));
   root.addContent(new Text(" "));
   root.addContent(new Text("  \n \n "));
   root.addContent(new Comment("Boo"));
   root.addContent(new Text("  \t "));
   root.addContent(new Text("  "));
   FormatSetup fs =
       new FormatSetup() {
         @Override
         public void setup(Format fmt) {
           fmt.setExpandEmptyElements(true);
         }
       };
   checkOutput(
       root,
       fs,
       "<root><![CDATA[ ]]>        \n \n <!--Boo-->  \t   </root>",
       "<root><!--Boo--></root>",
       "<root>\n  <!--Boo-->\n</root>",
       "<root>\n  <!--Boo-->\n</root>",
       "<root>\n  <!--Boo-->\n</root>");
 }
Exemplo n.º 30
0
  /**
   * Appends the content of a {@link Settings} object to the document.
   *
   * @param settings the {@link Settings} to write.
   */
  public void appendSettings(final Settings settings) {
    final Element settingsElement = new Element(SETTINGS_ELEMENT_KEY);

    final Element imageInfoElement = echoImageInfo(settings);
    settingsElement.addContent(imageInfoElement);

    final Element cropElement = echoCropSettings(settings);
    settingsElement.addContent(cropElement);

    final Element detectorElement = echoDetectorSettings(settings);
    settingsElement.addContent(detectorElement);

    final Element initFilter = echoInitialSpotFilter(settings);
    settingsElement.addContent(initFilter);

    final Element spotFiltersElement = echoSpotFilters(settings);
    settingsElement.addContent(spotFiltersElement);

    final Element trackerElement = echoTrackerSettings(settings);
    settingsElement.addContent(trackerElement);

    final Element trackFiltersElement = echoTrackFilters(settings);
    settingsElement.addContent(trackFiltersElement);

    final Element analyzersElement = echoAnalyzers(settings);
    settingsElement.addContent(analyzersElement);

    root.addContent(settingsElement);
  }