Esempio n. 1
0
 public static void main(final String[] args) throws IOException {
   final YAMLConfig cfg = YAML.config();
   final Serializer s =
       new SerializerImpl(new EmitterImpl(System.out, cfg), new ResolverImpl(), cfg);
   s.open();
   final Representer r = new RepresenterImpl(s, cfg);
   final Map test1 = new HashMap();
   final List test1Val = new LinkedList();
   test1Val.add("hello");
   test1Val.add(Boolean.TRUE);
   test1Val.add(new Integer(31337));
   test1.put("val1", test1Val);
   final List test2Val = new ArrayList();
   test2Val.add("hello");
   test2Val.add(Boolean.FALSE);
   test2Val.add(new Integer(31337));
   test1.put("val2", test2Val);
   test1.put("afsdf", "hmm");
   TestJavaBean bean1 = new TestJavaBean();
   bean1.setName("Ola");
   bean1.setSurName("Bini");
   bean1.setAge(24);
   test1.put(new Integer(25), bean1);
   r.represent(test1);
   s.close();
 }
Esempio n. 2
0
 public String toRDF() {
   Serializer sb = new Serializer();
   sb.open("kg:Index");
   sb.appendPNL("kg:index ", index);
   int total = 0;
   for (Node pred : getSortedProperties()) {
     int i = get(pred).size();
     if (i > 0) {
       total += i;
       sb.append("kg:item [ ");
       sb.appendP("rdf:predicate ", pred);
       sb.append("rdf:value ", i);
       sb.appendNL("] ;");
     }
   }
   sb.appendNL("kg:total ", total);
   sb.close();
   return sb.toString();
 }