Search in sources :

Example 1 with Select

use of com.dexels.navajo.document.stream.api.Select in project navajo by Dexels.

the class NavajoStreamCollector method createTmlProperty.

private Property createTmlProperty(Prop p) {
    Property result;
    if (Property.SELECTION_PROPERTY.equals(p.type())) {
        result = NavajoFactory.getInstance().createProperty(assemble, p.name(), p.cardinality().orElse(null), p.description(), p.direction().orElse(null));
        for (Select s : p.selections()) {
            Selection sel = NavajoFactory.getInstance().createSelection(assemble, s.name(), s.value(), s.selected());
            result.addSelection(sel);
        }
    } else {
        result = NavajoFactory.getInstance().createProperty(assemble, p.name(), p.type() == null ? Property.STRING_PROPERTY : p.type(), null, p.length(), p.description(), p.direction().orElse(null));
        if (p.value() != null) {
            result.setAnyValue(p.value());
        }
        if (p.type() != null) {
            result.setType(p.type());
        }
    }
    return result;
}
Also used : Selection(com.dexels.navajo.document.Selection) Select(com.dexels.navajo.document.stream.api.Select) Property(com.dexels.navajo.document.Property)

Example 2 with Select

use of com.dexels.navajo.document.stream.api.Select in project navajo by Dexels.

the class NavajoStreamToMutableMessageStream method createTmlProperty.

// private String currentPath() {
// StringBuilder sb = new StringBuilder();
// for (String path : tagStack) {
// sb.append(path);
// sb.append('/');
// }
// int len = sb.length();
// if(sb.charAt(len-1)=='/') {
// sb.deleteCharAt(len-1);
// }
// return sb.toString();
// }
private Property createTmlProperty(Prop p) {
    Property result;
    if (Property.SELECTION_PROPERTY.equals(p.type())) {
        result = NavajoFactory.getInstance().createProperty(null, p.name(), p.cardinality().orElse(null), p.description(), p.direction().orElse(null));
        for (Select s : p.selections()) {
            Selection sel = NavajoFactory.getInstance().createSelection(null, s.name(), s.value(), s.selected());
            result.addSelection(sel);
        }
    } else {
        result = NavajoFactory.getInstance().createProperty(null, p.name(), p.type() == null ? Property.STRING_PROPERTY : p.type(), null, p.length(), p.description(), p.direction().orElse(null));
        if (p.value() != null) {
            result.setAnyValue(p.value());
        }
        if (p.type() != null) {
            result.setType(p.type());
        }
    }
    return result;
}
Also used : Selection(com.dexels.navajo.document.Selection) Select(com.dexels.navajo.document.stream.api.Select) Property(com.dexels.navajo.document.Property)

Example 3 with Select

use of com.dexels.navajo.document.stream.api.Select in project navajo by Dexels.

the class NavajoDomStreamer method create.

private static Prop create(Property tmlProperty) {
    String type = tmlProperty.getType();
    List<Select> selections = selectFromTml(tmlProperty.getAllSelections());
    String value = null;
    Binary binary = null;
    if (Property.BINARY_PROPERTY.equals(type)) {
        value = null;
        binary = (Binary) tmlProperty.getTypedValue();
    } else if (Property.SELECTION_PROPERTY.equals(type)) {
        value = null;
    } else {
        value = tmlProperty.getValue();
    }
    Optional<Direction> direction = "in".equals(tmlProperty.getDirection()) ? Optional.of(Direction.IN) : "out".equals(tmlProperty.getDirection()) ? Optional.of(Direction.OUT) : Optional.empty();
    return Prop.create(tmlProperty.getName(), value, tmlProperty.getType(), selections, direction, tmlProperty.getDescription(), tmlProperty.getLength(), tmlProperty.getSubType(), Optional.ofNullable(tmlProperty.getCardinality()), binary);
}
Also used : Select(com.dexels.navajo.document.stream.api.Select) Binary(com.dexels.navajo.document.types.Binary) Direction(com.dexels.navajo.document.stream.api.Prop.Direction)

Aggregations

Select (com.dexels.navajo.document.stream.api.Select)3 Property (com.dexels.navajo.document.Property)2 Selection (com.dexels.navajo.document.Selection)2 Direction (com.dexels.navajo.document.stream.api.Prop.Direction)1 Binary (com.dexels.navajo.document.types.Binary)1