private static XStream getSchemaParser() {
    XStream xstream = new XStream(new Dom4JDriver());

    xstream.alias("object-schema", ObjectSchema.class);

    xstream.alias("record", Record.class);
    xstream.aliasAttribute(Record.class, "type", "type");
    xstream.aliasAttribute(Record.class, "entityType", "entityType");
    xstream.addImplicitCollection(Record.class, "subRecords", "record", Record.class);

    xstream.alias("field", Field.class);
    xstream.addImplicitCollection(Record.class, "fields", "field", Field.class);

    return xstream;
  }
Exemple #2
0
  public static void registerMapping(XStream xstream) {
    // In the XML the class is represented as a page - tag
    xstream.alias("page", CPNPage.class);

    xstream.useAttributeFor(CPNPage.class, "idattri");
    xstream.aliasAttribute(CPNPage.class, "idattri", "id");

    // In order not to display the places / transitions / arcs tag, but simply show
    // the page tags one after another.
    xstream.addImplicitCollection(CPNPage.class, "places", CPNPlace.class);
    xstream.addImplicitCollection(CPNPage.class, "transitions", CPNTransition.class);
    xstream.addImplicitCollection(CPNPage.class, "arcs", CPNArc.class);

    // Sometimes XStream cannot translate elements into a XML structure.
    // Therefore exists the possibility to create and register a converter for that element.
    xstream.registerConverter(new CPNTextConverter());

    // These instance variables are not needed for the mapping, that's why they are excluded
    xstream.omitField(CPNPage.class, "arcRelation");
    xstream.omitField(CPNPage.class, "nodePositions");

    // Giving all fields a concrete name for the XML
    xstream.aliasField("Aux", CPNPage.class, "auxtag");
    xstream.aliasField("group", CPNPage.class, "grouptag");
    xstream.aliasField("vguidelines", CPNPage.class, "vguidelines");
    xstream.aliasField("hguidelines", CPNPage.class, "hguidelines");

    CPNPageattr.registerMapping(xstream);
    CPNModellingThing.registerMapping(xstream);
    CPNPlace.registerMapping(xstream);
    CPNTransition.registerMapping(xstream);
    CPNArc.registerMapping(xstream);
    CPNLittleProperty.registerMapping(xstream);
  }
  /**
   * Reads the specified code coverage report in xml format. Uses xstream to convert from XML to
   * java object. Xstream aliases are used to bridge gap between xml format and java object
   * structure.
   *
   * @param coverageReport path to existing xml coverage report file
   * @return {@link ModuleCoverage} instance
   */
  public static ModuleCoverage getCoverageData(File coverageReport) {
    XStream xstream = new XStream();
    xstream.alias("coverage", ModuleCoverage.class);
    xstream.alias("package", PackageCoverage.class);
    xstream.alias("class", ClassCoverage.class);
    xstream.alias("method", MethodCoverage.class);
    xstream.alias("line", LineCoverage.class);
    xstream.alias("condition", ConditionCoverage.class);
    xstream.alias("source", String.class);
    xstream.useAttributeFor(ModuleCoverage.class, "timestamp");
    xstream.useAttributeFor(ModuleCoverage.class, "lineRate");
    xstream.useAttributeFor(ModuleCoverage.class, "branchRate");
    xstream.useAttributeFor(ModuleCoverage.class, "version");

    xstream.useAttributeFor(PackageCoverage.class, "name");
    xstream.useAttributeFor(PackageCoverage.class, "lineRate");
    xstream.useAttributeFor(PackageCoverage.class, "branchRate");
    xstream.useAttributeFor(PackageCoverage.class, "complexity");

    xstream.useAttributeFor(ClassCoverage.class, "name");
    xstream.useAttributeFor(ClassCoverage.class, "filename");
    xstream.useAttributeFor(ClassCoverage.class, "lineRate");
    xstream.useAttributeFor(ClassCoverage.class, "branchRate");
    xstream.useAttributeFor(ClassCoverage.class, "complexity");

    xstream.useAttributeFor(MethodCoverage.class, "name");
    xstream.useAttributeFor(MethodCoverage.class, "signature");
    xstream.useAttributeFor(MethodCoverage.class, "lineRate");
    xstream.useAttributeFor(MethodCoverage.class, "branchRate");

    xstream.useAttributeFor(LineCoverage.class, "number");
    xstream.useAttributeFor(LineCoverage.class, "hits");
    xstream.useAttributeFor(LineCoverage.class, "branch");
    xstream.useAttributeFor(LineCoverage.class, "conditionCoverage");

    xstream.useAttributeFor(ConditionCoverage.class, "number");
    xstream.useAttributeFor(ConditionCoverage.class, "type");
    xstream.useAttributeFor(ConditionCoverage.class, "coverage");

    xstream.aliasAttribute("condition-coverage", "conditionCoverage");
    xstream.aliasAttribute("line-rate", "lineRate");
    xstream.aliasAttribute("branch-rate", "branchRate");

    return (ModuleCoverage) xstream.fromXML(coverageReport);
  }
 public static XStream getXStream() {
   if (xStream == null) {
     synchronized (DashboardModelUtils.class) {
       if (xStream == null) {
         xStream = new XStream();
         xStream.alias("dashboard", Dashboard.class);
         xStream.alias("widget", Widget.class);
         xStream.alias("parameters", IParameters.class, Parameters.class);
         xStream.aliasAttribute(Dashboard.class, "title", "title");
         xStream.aliasAttribute(Dashboard.class, "layoutConstraints", "layoutConstraints");
         xStream.aliasAttribute(Dashboard.class, "rowConstraints", "rowConstraints");
         xStream.aliasAttribute(Dashboard.class, "colConstraints", "colConstraints");
         xStream.aliasAttribute(Widget.class, "classname", "classname");
         xStream.aliasAttribute(Widget.class, "id", "id");
         xStream.aliasAttribute(Widget.class, "style", "style");
         xStream.aliasAttribute(Widget.class, "title", "title");
         xStream.aliasAttribute(Widget.class, "collapsible", "collapsible");
         xStream.aliasAttribute(Widget.class, "collapsed", "collapsed");
         xStream.aliasAttribute(Widget.class, "hideTitleBar", "hideTitleBar");
         xStream.aliasAttribute(Widget.class, "layoutData", "layoutData");
         xStream.aliasAttribute(Widget.class, "listenToWidgets", "listenToWidgets");
         xStream.addImplicitCollection(Dashboard.class, "widgets", Widget.class);
         xStream.registerConverter(new ParametersConverter(xStream.getMapper()));
       }
     }
   }
   return xStream;
 }
  static {
    xstream.registerConverter(new JodaDateTimeXStreamConverter());
    xstream.addDefaultImplementation(ArrayList.class, List.class);

    xstream.addImplicitCollection(CHistoryItem.class, "attachments", CAttachment.class);
    xstream.alias("attachment", CAttachment.class);

    xstream.alias("organisation", COrganisation.class);
    xstream.alias("person", CPerson.class);

    xstream.alias("address", CAddress.class);
    xstream.alias("website", CWebsite.class);
    xstream.alias("email", CEmail.class);
    xstream.alias("phone", CPhone.class);

    xstream.alias("tags", CTags.class);
    xstream.aliasAttribute(CTags.class, "size", "size");
    xstream.addImplicitCollection(CTags.class, "tags", CTag.class);
    xstream.alias("tag", CTag.class);

    xstream.alias("tasks", CTasks.class);
    xstream.aliasAttribute(CTasks.class, "size", "size");
    xstream.addImplicitCollection(CTasks.class, "tasks", CTask.class);
    xstream.alias("task", CTask.class);

    xstream.alias("tracks", CTracks.class);
    xstream.addImplicitCollection(CTracks.class, "tracks", CTrack.class);
    xstream.alias("track", CTrack.class);

    xstream.alias("users", CUsers.class);
    xstream.addImplicitCollection(CUsers.class, "users", CUser.class);
    xstream.alias("user", CUser.class);

    xstream.alias("history", CHistory.class);
    xstream.aliasAttribute(CHistory.class, "size", "size");
    xstream.addImplicitCollection(CHistory.class, "historyItems", CHistoryItem.class);
    xstream.alias("historyItem", CHistoryItem.class);

    xstream.alias("parties", CParties.class);
    xstream.aliasAttribute(CParties.class, "size", "size");
    xstream.addImplicitCollection(CParties.class, "organisations", COrganisation.class);
    xstream.addImplicitCollection(CParties.class, "persons", CPerson.class);

    xstream.alias("customField", CCustomField.class);
    xstream.aliasField("boolean", CCustomField.class, "bool");
    xstream.alias("customFields", CCustomFields.class);
    xstream.aliasAttribute(CCustomFields.class, "size", "size");
    xstream.addImplicitCollection(CCustomFields.class, "customFields", CCustomField.class);

    xstream.alias("customFieldDefinition", CCustomFieldDefinition.class);
    xstream.alias("customFieldDefinitions", CCustomFieldDefinitions.class);
    xstream.addImplicitCollection(
        CCustomFieldDefinitions.class, "customFieldDefinitions", CCustomFieldDefinition.class);

    xstream.alias("opportunities", COpportunities.class);
    xstream.addImplicitCollection(COpportunities.class, "opportunities", COpportunity.class);
    xstream.alias("opportunity", COpportunity.class);

    xstream.alias("milestones", CMilestones.class);
    xstream.addImplicitCollection(CMilestones.class, "milestones", CMilestone.class);
    xstream.alias("milestone", CMilestone.class);
  }