Beispiel #1
0
 private static void addCategoriesHeaders(ValueTable table, List<String> headers) {
   for (Variable variable : table.getVariables()) {
     for (Category category : variable.getCategories()) {
       for (Attribute attribute : category.getAttributes()) {
         if (attribute.getName().equals(VariableConverter.LABEL) && attribute.isLocalised()) {
           String header = VariableConverter.CATEGORIES + ":" + attribute.getLocale();
           if (!headers.contains(header)) {
             headers.add(header);
           }
         }
       }
     }
   }
   if (!headers.get(headers.size() - 1).startsWith(VariableConverter.CATEGORIES)) {
     headers.add(VariableConverter.CATEGORIES);
   }
 }
    /** Returns an iterator of category names */
    private Iterator<String> categoryNames() {
      if (variable.getValueType().equals(BooleanType.get())) {
        return ImmutableList.<String>builder() //
            .add(BooleanType.get().trueValue().toString()) //
            .add(BooleanType.get().falseValue().toString())
            .build()
            .iterator();
      }

      return Iterables.transform(
              variable.getCategories(),
              new Function<Category, String>() {

                @Override
                public String apply(Category from) {
                  return from.getName();
                }
              })
          .iterator();
    }