Example #1
0
 public Model getModel() {
   Model model = ModelFactory.createDefaultModel();
   Resource itemNode = model.createResource(uri);
   for (Prop prop : values) {
     if (prop.isLiteral()) {
       itemNode.addLiteral(prop.getType(), model.createLiteral(prop.getValue()));
     } else {
       itemNode.addProperty(prop.getType(), model.createResource(prop.getValue()));
     }
   }
   return model;
 }
Example #2
0
  /**
   * Initializes this object loading the initialization parameters. Does nothing if this method has
   * already been called, even if the previous call threw any exception.
   *
   * @throws Exception If any required parameter is undefined.
   */
  public void init(ServletConfig sc, Log log) throws Exception {
    if (!initCalled) {
      initCalled = true;
      // Read in the required properties:
      for (Prop prop : Prop.values()) {
        String value = sc.getInitParameter(prop.getName());
        if (value != null && value.trim().length() > 0) {
          prop.setValue(value);
        } else if (prop.getValue() == null) {
          throw new Exception("Required init parameter not defined: " + prop.getName());
        }
      }

      if (log != null && log.isDebugEnabled()) {
        for (Prop prop : Prop.values()) {
          log.debug(prop.getName() + " = " + prop.getValue());
        }
      }
    }
  }
Example #3
0
  @Override
  public String toString() {
    String content = "Item description:" + this.getUri();

    Iterator i = values.iterator();

    while (i.hasNext()) {
      Prop me = (Prop) i.next();
      String isL = "Uri";
      if (me.isLiteral()) isL = "Lit";
      String isS = " ";
      if (me.isIsSearchable()) isS = "*";
      content += "\n\t" + isS + " " + isL + " " + me.getType() + " : ";
      if (me.getValue().length() > 100) {
        content += me.getValue().substring(0, 100) + "...";
      } else {
        content += me.getValue();
      }
    }
    return content;
  }