@Override public void visit(OWLLiteral node) { write("\""); write(node.getLiteral()); write("\"\\^\\^"); write(node.getDatatype().getIRI()); }
private String getAnnotationValueByUri(OWLOntology o, OWLEntity owlEntity, String uri) { for (OWLAnnotation annotation : owlEntity.getAnnotations(o)) { if (annotation.getProperty().getIRI().toString().equals(uri)) { OWLLiteral value = (OWLLiteral) annotation.getValue(); return value.getLiteral(); } } return null; }
public static String getLabel(OWLOntology o, OWLEntity owlEntity) { for (OWLAnnotation annotation : owlEntity.getAnnotations(o)) { if (annotation.getProperty().isLabel()) { OWLLiteral value = (OWLLiteral) annotation.getValue(); return value.getLiteral(); } } return owlEntity.getIRI().toString(); }
@Override public void visit(OWLLiteral node) { node.getDatatype().accept(this); OWLDatatype dt = (OWLDatatype) obj; if (node.hasLang()) { obj = dataFactory.getOWLLiteral(node.getLiteral(), node.getLang()); } else { obj = dataFactory.getOWLLiteral(node.getLiteral(), dt); } }
/** * Translates and consumes the cardinality triple. * * @param mainNode The main node of the restriction. * @return The cardinality of the restriction. */ private int translateCardinality(IRI mainNode) { OWLLiteral cardiObject = getLiteralObject(mainNode, getCardinalityTriplePredicate(), true); if (cardiObject == null) { cardiObject = getLiteralObject(mainNode, getQualifiedCardinalityTriplePredicate(), true); } if (cardiObject == null) { return -1; } return Integer.parseInt(cardiObject.getLiteral()); }
public boolean equals(Object obj) { if (super.equals(obj)) { if (!(obj instanceof OWLLiteral)) { return false; } OWLLiteral other = (OWLLiteral) obj; return literal.equals(other.getLiteral()) && datatype.equals(other.getDatatype()) && lang.equals(other.getLang()); } return false; }
@Override protected int compareObjectOfSameType(OWLObject object) { OWLLiteral other = (OWLLiteral) object; int diff = literal.compareTo(other.getLiteral()); if (diff != 0) { return diff; } diff = datatype.compareTo(other.getDatatype()); if (diff != 0) { return diff; } return lang.compareTo(other.getLang()); }
protected ArrayList<PossibleValueType> getAnnotationValuesByUri( OWLOntology o, OWLEntity owlEntity, String uri) { ArrayList<PossibleValueType> possibleValueTypes = new ArrayList<PossibleValueType>(); for (OWLAnnotation annotation : owlEntity.getAnnotations(o)) { if (annotation.getProperty().getIRI().toString().equals(uri)) { OWLLiteral value = (OWLLiteral) annotation.getValue(); String[] possibleValues = value.getLiteral().split(","); for (String possibleValue : possibleValues) { String[] parsedValue = possibleValue.split(":"); checkArgument( parsedValue.length == 2, "Possible values must be in the format mapping:value"); possibleValueTypes.add(new PossibleValueType(parsedValue[0], parsedValue[1])); } } } return possibleValueTypes; }
private void appendTag( Paragraph tagParagraph, OWLLiteral literal, Color foreground, boolean isSelected) { Color tagColor = isSelected ? foreground : Color.GRAY; Color tagValueColor = isSelected ? foreground : Color.GRAY; if (literal.hasLang()) { tagParagraph.append("[language: ", tagColor); tagParagraph.append(literal.getLang(), tagValueColor); tagParagraph.append("]", tagColor); } else if (datatypeRendering == RENDER_DATATYPE_INLINE && !literal.isRDFPlainLiteral()) { tagParagraph.append("[type: ", tagColor); tagParagraph.append( editorKit.getOWLModelManager().getRendering(literal.getDatatype()), tagValueColor); tagParagraph.append("]", tagColor); } // if (ontology != null) { // tagParagraph.append(" ", foreground); // tagParagraph.append("[in: ", tagColor); // String ontologyRendering = editorKit.getOWLModelManager().getRendering(ontology); // tagParagraph.append(ontologyRendering, tagColor); // tagParagraph.append("]", tagColor); // } }
public void visit(OWLLiteral node) { if (preferredLanguages == null || preferredLanguages.isEmpty()) { // if there are no languages just match the first thing lastLangMatchIndex = 0; candidateValue = node; } else { final int index = preferredLanguages.indexOf(node.getLang()); if (index >= 0 && index < lastLangMatchIndex) { lastLangMatchIndex = index; candidateValue = node; } } }
/** * Renders an annotation value that is an OWLLiteral. * * @param page The page that the value will be rendered into. * @param literal The literal to be rendered. * @param foreground The default foreground. * @param background The default background. * @param isSelected Whether or not the cell containing the annotation value is selected. * @return A list of paragraphs that represent the rendering of the literal. */ private List<Paragraph> renderLiteral( Page page, OWLLiteral literal, Color foreground, Color background, boolean isSelected) { String rendering = EscapeUtils.unescapeString(literal.getLiteral()).trim(); List<Paragraph> result = new ArrayList<>(); if (rendering.length() > 0) { List<LinkSpan> linkSpans = extractLinks(rendering); Paragraph literalParagraph = new Paragraph(rendering, linkSpans); literalParagraph.setForeground(foreground); page.add(literalParagraph); result.add(literalParagraph); Paragraph tagParagraph = literalParagraph; // new Paragraph(""); tagParagraph.append(" ", foreground); page.add(tagParagraph); result.add(tagParagraph); tagParagraph.setMarginTop(2); tagParagraph.setTabCount(2); // appendTag(tagParagraph, literal, foreground, isSelected); } return result; }
public void visit(OWLLiteral node) { node.getDatatype().accept(this); }
public void visit(OWLDataOneOf node) { for (OWLLiteral val : node.getValues()) { val.accept(this); } }