The following document contains the results of PMD's CPD 5.3.2.

Duplications

File Project Line
eu/fbk/knowledgestore/datastore/hbase/utils/AvroSerializer.java ks-server-hbase 272
eu/fbk/knowledgestore/runtime/SerializerAvro.java ks-server 278
            } else if (schema.equals(AvroSchemas.CALENDAR)) {
                final int tz = (Integer) record.get(0);
                final GregorianCalendar calendar = new GregorianCalendar();
                calendar.setTimeInMillis((Long) record.get(1));
                calendar.setTimeZone(TimeZone.getTimeZone(String.format("GMT%s%02d:%02d",
                        tz >= 0 ? "+" : "-", Math.abs(tz) / 60, Math.abs(tz) % 60)));
                return this.factory.createLiteral(this.datatypeFactory
                        .newXMLGregorianCalendar(calendar));
            }
        } else if (generic instanceof CharSequence) {
            return this.factory.createLiteral(generic.toString()); // Utf8 class used
        } else if (generic instanceof Boolean) {
            return this.factory.createLiteral((Boolean) generic);
        } else if (generic instanceof Long) {
            return this.factory.createLiteral((Long) generic);
        } else if (generic instanceof Integer) {
            return this.factory.createLiteral((Integer) generic);
        } else if (generic instanceof Double) {
            return this.factory.createLiteral((Double) generic);
        } else if (generic instanceof Float) {
            return this.factory.createLiteral((Float) generic);
        }
        Preconditions.checkNotNull(generic);
        throw new IllegalArgumentException("Unsupported generic data: " + generic);
    }

    private Statement decodeStatement(final GenericRecord record) {
        final Resource subj = decodeIdentifier((GenericRecord) record.get(0));
        final URI pred = (URI) decodeIdentifier((GenericRecord) record.get(1));
        final Value obj = decodeValue(record.get(2));
        final Resource ctx = decodeIdentifier((GenericRecord) record.get(3));
        if (ctx == null) {
            return this.factory.createStatement(subj, pred, obj);
        } else {
            return this.factory.createStatement(subj, pred, obj, ctx);
        }
    }

    private Object encodeNodes(final Iterable<? extends Object> nodes) {
        final int size = Iterables.size(nodes);
        if (size == 1) {
            return encodeNode(Iterables.get(nodes, 0));
        }
        final List<Object> list = Lists.<Object>newArrayListWithCapacity(size);
        for (final Object node : nodes) {
            list.add(encodeNode(node));
        }
        return list;
    }

    private Object encodeNode(final Object node) {
        if (node instanceof Record) {
            return encodeRecord((Record) node, null);
        } else if (node instanceof Literal) {
            return encodeLiteral((Literal) node);
        } else if (node instanceof Resource) {
            return encodeIdentifier((Resource) node);
        } else if (node instanceof Statement) {
            return encodeStatement((Statement) node);
        }
        Preconditions.checkNotNull(node);
        throw new IllegalArgumentException("Unsupported node: " + node);
    }

    private Object encodeRecord(final Record record, @Nullable final Set<URI> propertiesToEncode) {
        final URI id = record.getID();
        final Object encodedID = id == null ? null : encodeIdentifier(id);
        final List<Object> props = Lists.newArrayList();
        for (final URI property : record.getProperties()) {
            if (propertiesToEncode == null || propertiesToEncode.contains(property)) {
                ensureInDictionary(property);
                final List<? extends Object> nodes = record.get(property);
                if (property.equals(RDF.TYPE)) {
                    for (final Object value : nodes) {
                        if (value instanceof URI) {
                            ensureInDictionary((URI) value);
                        }
                    }
                }
                final GenericData.Record prop = new GenericData.Record(AvroSchemas.PROPERTY);
File Project Line
eu/fbk/knowledgestore/datastore/hbase/utils/AvroSerializer.java ks-server-hbase 99
eu/fbk/knowledgestore/runtime/SerializerAvro.java ks-server 105
                    AvroSchemas.COMPRESSED_IDENTIFIER);
            final Object generic = reader.read(null, decoder);
            return (URI) decodeNode(generic);

        } catch (final IOException ex) {
            throw new Error("Unexpected exception (!): " + ex.getMessage(), ex);
        }
    }

    public byte[] toBytes(final Object object) {
        try {
            final ByteArrayOutputStream stream = new ByteArrayOutputStream();
            this.toStream(stream, object);
            return stream.toByteArray();
        } catch (final IOException ex) {
            throw new Error("Unexpected exception (!): " + ex.getMessage(), ex);
        }
    }

    public byte[] toBytes(final Record object, @Nullable final Set<URI> propertiesToSerialize) {
        try {
            final ByteArrayOutputStream stream = new ByteArrayOutputStream();
            this.toStream(stream, object, propertiesToSerialize);
            return stream.toByteArray();
        } catch (final IOException ex) {
            throw new Error("Unexpected exception (!): " + ex.getMessage(), ex);
        }
    }

    public Object fromBytes(final byte[] bytes) {
        try {
            return this.fromStream(new ByteArrayInputStream(bytes));
        } catch (final IOException ex) {
            throw new Error("Unexpected exception (!): " + ex.getMessage(), ex);
        }
    }

    public Record fromBytes(final byte[] bytes, final @Nullable Set<URI> propertiesToDeserialize) {
        try {
            return this.fromStream(new ByteArrayInputStream(bytes), propertiesToDeserialize);
        } catch (final IOException ex) {
            throw new Error("Unexpected exception (!): " + ex.getMessage(), ex);
        }
    }

    public void toStream(final OutputStream stream, final Object object) throws IOException {
        final Object generic = encodeNode(object);
        final Encoder encoder = EncoderFactory.get().directBinaryEncoder(stream, null);
        final DatumWriter<Object> writer = new GenericDatumWriter<Object>(AvroSchemas.NODE);
File Project Line
eu/fbk/knowledgestore/datastore/hbase/utils/AvroSerializer.java ks-server-hbase 200
eu/fbk/knowledgestore/runtime/SerializerAvro.java ks-server 206
            } else if (schema.equals(AvroSchemas.STATEMENT)) {
                return decodeStatement(record);
            }
        }
        return decodeLiteral(generic);
    }

    @SuppressWarnings("unchecked")
    private Record decodeRecord(final GenericRecord generic,
            @Nullable final Set<URI> propertiesToDecode) {
        final Record record = Record.create();
        final GenericRecord encodedID = (GenericRecord) generic.get(0);
        if (encodedID != null) {
            record.setID((URI) decodeIdentifier(encodedID));
        }
        for (final GenericRecord prop : (Iterable<GenericRecord>) generic.get(1)) {
            final URI property = (URI) decodeIdentifier((GenericRecord) prop.get(0));
            final List<Object> values = decodeNodes(prop.get(1));
            if (propertiesToDecode == null || propertiesToDecode.contains(property)) {
                record.set(property, values);
            }
        }
        return record;
    }

    private Value decodeValue(final Object generic) {
        if (generic instanceof GenericRecord) {
            final GenericRecord record = (GenericRecord) generic;
            final Schema schema = record.getSchema();
            if (schema.equals(AvroSchemas.COMPRESSED_IDENTIFIER)
File Project Line
eu/fbk/knowledgestore/populator/naf/model/Component.java ks-populator-naf 34
eu/fbk/knowledgestore/populator/naf/model/Term.java ks-populator-naf 34
public class Component {

    @XmlAttribute(name = "id", required = true)
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlID
    protected String id;
    @XmlAttribute(name = "type")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String type;
    @XmlAttribute(name = "lemma")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String lemma;
    @XmlAttribute(name = "pos")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String pos;
    @XmlAttribute(name = "morphofeat")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String morphofeat;
    @XmlAttribute(name = "netype")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String netype;
    @XmlAttribute(name = "case")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String _case;
    @XmlAttribute(name = "head")
    @XmlJavaTypeAdapter(NormalizedStringAdapter.class)
    protected String head;
    @XmlElements({
        @XmlElement(name = "sentiment", required = true, type = Sentiment.class),
        @XmlElement(name = "span", required = true, type = Span.class),
        @XmlElement(name = "externalReferences", required = true, type = ExternalReferences.class)
File Project Line
eu/fbk/knowledgestore/populator/naf/model/Component.java ks-populator-naf 76
eu/fbk/knowledgestore/populator/naf/model/Term.java ks-populator-naf 77
    public String getId() {
        return id;
    }

    /**
     * Sets the value of the id property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setId(String value) {
        this.id = value;
    }

    /**
     * Gets the value of the type property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setType(String value) {
        this.type = value;
    }

    /**
     * Gets the value of the lemma property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLemma() {
        return lemma;
    }

    /**
     * Sets the value of the lemma property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLemma(String value) {
        this.lemma = value;
    }

    /**
     * Gets the value of the pos property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getPos() {
        return pos;
    }

    /**
     * Sets the value of the pos property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setPos(String value) {
        this.pos = value;
    }

    /**
     * Gets the value of the morphofeat property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getMorphofeat() {
        return morphofeat;
    }

    /**
     * Sets the value of the morphofeat property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setMorphofeat(String value) {
        this.morphofeat = value;
    }

    /**
     * Gets the value of the netype property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getNetype() {
        return netype;
    }

    /**
     * Sets the value of the netype property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setNetype(String value) {
        this.netype = value;
    }

    /**
     * Gets the value of the case property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCase() {
        return _case;
    }

    /**
     * Sets the value of the case property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setCase(String value) {
        this._case = value;
    }

    /**
     * Gets the value of the head property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getHead() {
        return head;
    }

    /**
     * Sets the value of the head property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setHead(String value) {
        this.head = value;
    }

    /**
     * Gets the value of the sentimentOrSpanOrExternalReferences property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the sentimentOrSpanOrExternalReferences property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getSentimentOrSpanOrExternalReferences().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Sentiment }
     * {@link Span }
     * {@link ExternalReferences }
     * 
     * 
     */
    public List<Object> getSentimentOrSpanOrExternalReferences() {
File Project Line
eu/fbk/knowledgestore/populator/naf/model/Component.java ks-populator-naf 61
eu/fbk/knowledgestore/populator/naf/model/Mark.java ks-populator-naf 58
    @XmlElements({
        @XmlElement(name = "sentiment", required = true, type = Sentiment.class),
        @XmlElement(name = "span", required = true, type = Span.class),
        @XmlElement(name = "externalReferences", required = true, type = ExternalReferences.class)
    })
    protected List<Object> sentimentOrSpanOrExternalReferences;

    /**
     * Gets the value of the id property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getId() {
        return id;
    }

    /**
     * Sets the value of the id property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setId(String value) {
        this.id = value;
    }

    /**
     * Gets the value of the type property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setType(String value) {
        this.type = value;
    }

    /**
     * Gets the value of the lemma property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLemma() {
        return lemma;
    }

    /**
     * Sets the value of the lemma property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLemma(String value) {
        this.lemma = value;
    }

    /**
     * Gets the value of the pos property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getPos() {
        return pos;
    }

    /**
     * Sets the value of the pos property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setPos(String value) {
        this.pos = value;
    }

    /**
     * Gets the value of the morphofeat property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getMorphofeat() {
        return morphofeat;
    }

    /**
     * Sets the value of the morphofeat property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setMorphofeat(String value) {
        this.morphofeat = value;
    }

    /**
     * Gets the value of the netype property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getNetype() {
File Project Line
eu/fbk/knowledgestore/datastore/hbase/utils/AvroSerializer.java ks-server-hbase 172
eu/fbk/knowledgestore/runtime/SerializerAvro.java ks-server 178
                AvroSchemas.NODE);
        final GenericRecord generic = reader.read(null, decoder);
        return decodeRecord(generic, propertiesToDeserialize);
    }

    private List<Object> decodeNodes(final Object generic) {
        if (generic instanceof Iterable<?>) {
            final Iterable<?> iterable = (Iterable<?>) generic;
            final int size = Iterables.size(iterable);
            final List<Object> nodes = Lists.<Object>newArrayListWithCapacity(size);
            for (final Object element : iterable) {
                nodes.add(decodeNode(element));
            }
            return nodes;
        }
        Preconditions.checkNotNull(generic);
        return ImmutableList.of(decodeNode(generic));
    }

    private Object decodeNode(final Object generic) {
        if (generic instanceof GenericRecord) {
            final GenericRecord record = (GenericRecord) generic;
            final Schema schema = record.getSchema();
            if (schema.equals(AvroSchemas.RECORD)) {
File Project Line
eu/fbk/knowledgestore/triplestore/virtuoso/VirtuosoTripleTransaction.java ks-server-virtuoso 93
eu/fbk/knowledgestore/triplestore/RepositoryTripleStore.java ks-server 127
            throw new IOException("Cannot setup read-only transaction", ex);
        }

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(this + " started in " + (readOnly ? "read-only" : "read-write")
                    + " mode, " + (System.currentTimeMillis() - ts) + " ms");
        }
    }

    private void checkWritable() {
        if (this.readOnly) {
            throw new IllegalStateException("Write operation not allowed on read-only transaction");
        }
    }

    @Nullable
    private <T, E extends Exception> CloseableIteration<T, E> logClose(
            @Nullable final CloseableIteration<T, E> iteration) {
        if (iteration == null || !LOGGER.isDebugEnabled()) {
            return iteration;
        }
        final long ts = System.currentTimeMillis();
        return new IterationWrapper<T, E>(iteration) {

            @Override
            protected void handleClose() throws E {
                try {
                    super.handleClose();
                } finally {
                    LOGGER.debug("Virtuoso iteration closed after {} ms",
File Project Line
eu/fbk/knowledgestore/datastore/hbase/HBaseDataTransaction.java ks-server-hbase 110
eu/fbk/knowledgestore/datastore/hbase/HBaseDataTransaction.java ks-server-hbase 142
        if (KS.RESOURCE.equals(type)) {
            tableName = hbaseUtils.getHbaseTableNamePrefix() + DEFAULT_RES_TAB_NAME;
            familyName = DEFAULT_RES_FAM_NAME;
        } else if (KS.MENTION.equals(type)) {
            tableName = hbaseUtils.getHbaseTableNamePrefix() + DEFAULT_MEN_TAB_NAME;
            familyName = DEFAULT_MEN_FAM_NAME;
        } else if (KS.ENTITY.equals(type)) {
            tableName = hbaseUtils.getHbaseTableNamePrefix() + DEFAULT_ENT_TAB_NAME;
            familyName = DEFAULT_ENT_FAM_NAME;
        } else if (KS.CONTEXT.equals(type)) {
            tableName = hbaseUtils.getHbaseTableNamePrefix() + DEFAULT_CON_TAB_NAME;
            familyName = DEFAULT_CON_FAM_NAME;
        } else if (KS.USER.equals(type)) {
            tableName = hbaseUtils.getHbaseTableNamePrefix() + DEFAULT_USR_TAB_NAME;
            familyName = DEFAULT_USR_FAM_NAME;
        } else {
            throw new IllegalArgumentException("Unsupported record type "
                    + Data.toString(type, Data.getNamespaceMap()));
        }

        return Stream.create(new HBaseScanIterator(hbaseUtils, tableName, familyName,
File Project Line
eu/fbk/knowledgestore/datastore/hbase/utils/AvroSerializer.java ks-server-hbase 423
eu/fbk/knowledgestore/runtime/SerializerAvro.java ks-server 429
        return AvroSerializer.newGenericRecord(AvroSchemas.STATEMENT,
                encodeIdentifier(statement.getSubject()),
                encodeIdentifier(statement.getPredicate()), //
                encodeValue(statement.getObject()), //
                encodeIdentifier(statement.getContext()));
    }

    private URI ensureInDictionary(final URI uri) {
        try {
            this.dictionary.keyFor(uri);
            return uri;
        } catch (final IOException ex) {
            throw new IllegalStateException("Cannot access dictionary: " + ex.getMessage(), ex);
        }
    }

    private static GenericData.Record newGenericRecord(final Schema schema,
            final Object... fieldValues) {

        final GenericData.Record record = new GenericData.Record(schema);
        for (int i = 0; i < fieldValues.length; ++i) {
            record.put(i, fieldValues[i]);
        }
        return record;
    }
File Project Line
eu/fbk/knowledgestore/datastore/hbase/utils/AvroSerializer.java ks-server-hbase 393
eu/fbk/knowledgestore/runtime/SerializerAvro.java ks-server 399
                return AvroSerializer.newGenericRecord(AvroSchemas.STRING_LANG,
                        literal.getLabel(), language);
            }
        } else if (datatype.equals(XMLSchema.BOOLEAN)) {
            return literal.booleanValue();
        } else if (datatype.equals(XMLSchema.LONG)) {
            return literal.longValue();
        } else if (datatype.equals(XMLSchema.INT)) {
            return literal.intValue();
        } else if (datatype.equals(XMLSchema.DOUBLE)) {
            return literal.doubleValue();
        } else if (datatype.equals(XMLSchema.FLOAT)) {
            return literal.floatValue();
        } else if (datatype.equals(XMLSchema.SHORT)) {
            return AvroSerializer.newGenericRecord(AvroSchemas.SHORT, literal.intValue());
File Project Line
eu/fbk/knowledgestore/server/http/jaxrs/Crud.java ks-server-http 162
eu/fbk/knowledgestore/server/http/jaxrs/Crud.java ks-server-http 219
                    .records(records);
        } catch (final IllegalArgumentException ex) {
            throw new OperationException(newOutcome(Outcome.Status.ERROR_INVALID_INPUT,
                    ex.getMessage()), ex);
        }

        // Validate client preconditions and handle probing
        init(true, null);

        // Setup record decoding
        records.setProperty("types", ImmutableList.of(getRecordType()));
        closeOnCompletion(records);

        // Perform the operation
        final List<Outcome> outcomes = Lists.newArrayList();
        operation.exec(outcomes);

        // Setup the resulting stream
        final Stream<Outcome> entity = Stream.create(outcomes);
        entity.setProperty("types", ImmutableSet.of(KSR.INVOCATION));

        // final Stream<Outcome> entity = new Stream<Outcome>() {
        //
        // @Override
        // protected void doToHandler(final Handler<? super Outcome> handler) {
        // try {
        // operation.exec(handler);
        // } catch (final Throwable ex) {
        // propagateIfNotBulk(ex);
        // }
        // }
        //
        // };

        // Stream the results in the HTTP response
        return newResponseBuilder(Status.OK, entity, Protocol.STREAM_OF_OUTCOMES).build();
    }

    @POST
    @Path(Protocol.SUBPATH_MERGE)
File Project Line
eu/fbk/knowledgestore/server/http/jaxrs/RenderUtils.java ks-server-http 398
eu/fbk/knowledgestore/server/http/jaxrs/TableQuery.java ks-server-http 126
        out.append("<thead>\n<tr><th>URI</th>");
        for (final URI propertyURI : propertyURIs) {
            out.append("<th>").append(RenderUtils.shortenURI(propertyURI)).append("</th>");
        }
        out.append("</tr>\n</thead>\n<tbody>\n");
        for (final Record record : records) {
            out.append("<tr><td>").append(RenderUtils.render(record.getID())).append("</td>");
            for (final URI propertyURI : propertyURIs) {
                out.append("<td>").append(RenderUtils.render(record.get(propertyURI)))
                        .append("</td>");
            }
            out.append("</tr>\n");
        }
        out.append("</tbody>\n</table>\n");
File Project Line
eu/fbk/knowledgestore/tool/TestDriver.java ks-tool 123
eu/fbk/knowledgestore/tool/TestGenerator.java ks-tool 77
                    .withLogger(LoggerFactory.getLogger("eu.fbk.nwrtools")).parse(args);

            final File configFile = cmd.getOptionValue("c", File.class);

            final Properties config = new Properties();
            try (InputStream configStream = IO.read(configFile.getAbsolutePath())) {
                config.load(configStream);
            }

            for (final String arg : cmd.getArgs(String.class)) {
                final int index = arg.indexOf('=');
                if (index > 0) {
                    final String name = arg.substring(0, index);
                    final String value = arg.substring(index + 1);
                    config.setProperty(name, value);
                }
            }

            new TestDriver(config, configFile.getParentFile()).run();
File Project Line
eu/fbk/knowledgestore/data/XPath.java ks-core 435
eu/fbk/knowledgestore/data/XPath.java ks-core 519
                        final int start = i;
                        while (i < length && (string.charAt(i) == ':' //
                                || string.charAt(i) == '_' //
                                || string.charAt(i) == '-' //
                                || string.charAt(i) == '.' //
                        || Character.isLetterOrDigit(string.charAt(i)))) {
                            ++i;
                        }
                        final String qname = string.substring(start, i);
                        final String prefix = qname.substring(0, qname.indexOf(':'));
                        final URI uri = (URI) Data.parseValue(qname, inNamespaces);
                        outNamespaces.put(prefix, uri.getNamespace());
File Project Line
eu/fbk/knowledgestore/populator/naf/model/Mark.java ks-populator-naf 73
eu/fbk/knowledgestore/populator/naf/model/Term.java ks-populator-naf 77
    public String getId() {
        return id;
    }

    /**
     * Sets the value of the id property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setId(String value) {
        this.id = value;
    }

    /**
     * Gets the value of the type property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getType() {
        return type;
    }

    /**
     * Sets the value of the type property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setType(String value) {
        this.type = value;
    }

    /**
     * Gets the value of the lemma property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getLemma() {
        return lemma;
    }

    /**
     * Sets the value of the lemma property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setLemma(String value) {
        this.lemma = value;
    }

    /**
     * Gets the value of the pos property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getPos() {
        return pos;
    }

    /**
     * Sets the value of the pos property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setPos(String value) {
        this.pos = value;
    }

    /**
     * Gets the value of the morphofeat property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getMorphofeat() {
        return morphofeat;
    }

    /**
     * Sets the value of the morphofeat property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setMorphofeat(String value) {
        this.morphofeat = value;
    }

    /**
     * Gets the value of the case property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getCase() {
File Project Line
eu/fbk/knowledgestore/populator/naf/model/OpinionExpression.java ks-populator-naf 59
eu/fbk/knowledgestore/populator/naf/model/Sentiment.java ks-populator-naf 85
    public String getPolarity() {
        return polarity;
    }

    /**
     * Sets the value of the polarity property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setPolarity(String value) {
        this.polarity = value;
    }

    /**
     * Gets the value of the strength property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getStrength() {
        return strength;
    }

    /**
     * Sets the value of the strength property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setStrength(String value) {
        this.strength = value;
    }

    /**
     * Gets the value of the subjectivity property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSubjectivity() {
        return subjectivity;
    }

    /**
     * Sets the value of the subjectivity property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSubjectivity(String value) {
        this.subjectivity = value;
    }

    /**
     * Gets the value of the sentimentSemanticType property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSentimentSemanticType() {
        return sentimentSemanticType;
    }

    /**
     * Sets the value of the sentimentSemanticType property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSentimentSemanticType(String value) {
        this.sentimentSemanticType = value;
    }

    /**
     * Gets the value of the sentimentProductFeature property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getSentimentProductFeature() {
        return sentimentProductFeature;
    }

    /**
     * Sets the value of the sentimentProductFeature property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setSentimentProductFeature(String value) {
        this.sentimentProductFeature = value;
    }

    /**
     * Gets the value of the span property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the span property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getSpan().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Span }
     * 
     * 
     */
    public List<Span> getSpan() {
File Project Line
eu/fbk/knowledgestore/datastore/hbase/utils/AvroSerializer.java ks-server-hbase 82
eu/fbk/knowledgestore/runtime/SerializerAvro.java ks-server 88
                    AvroSchemas.COMPRESSED_IDENTIFIER);
            this.dictionary.keyFor(uri); // ensure a compressed version of URI is available
            final Object generic = encodeIdentifier(uri);
            writer.write(generic, encoder);
            return stream.toByteArray();

        } catch (final IOException ex) {
            throw new Error("Unexpected exception (!): " + ex.getMessage(), ex);
        }
    }

    public URI expandURI(final byte[] bytes) {
        Preconditions.checkNotNull(bytes);
        try {
            final InputStream stream = new ByteArrayInputStream(bytes);
            final Decoder decoder = DecoderFactory.get().directBinaryDecoder(stream, null);
            final DatumReader<Object> reader = new GenericDatumReader<Object>(
File Project Line
eu/fbk/knowledgestore/server/http/jaxrs/Root.java ks-server-http 218
eu/fbk/knowledgestore/runtime/Launcher.java ks-server 551
                .append(minutes).append("m uptime, ").append(gctime * 100 / uptime).append("% gc");

        // Emit memory usage
        final MemoryUsage heap = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
        final MemoryUsage nonHeap = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
        final long used = heap.getUsed() + nonHeap.getUsed();
        final long committed = heap.getCommitted() + nonHeap.getCommitted();
        final long mb = 1024 * 1024;
        long max = 0;
        for (final MemoryPoolMXBean bean : ManagementFactory.getMemoryPoolMXBeans()) {
            max += bean.getPeakUsage().getUsed(); // assume maximum at same time in all pools
        }
        builder.append("; ").append(used / mb).append("/").append(max / mb).append("/")
File Project Line
eu/fbk/knowledgestore/data/Data.java ks-core 1106
eu/fbk/knowledgestore/data/Data.java ks-core 1154
        for (int i = 0; i < string.length(); ++i) {
            final char c = string.charAt(i);
            if (c >= 'a' && c <= 'z' || c >= '?' && c <= '[' || c >= '&' && c <= ';' || c == '#'
                    || c == '$' || c == '!' || c == '=' || c == ']' || c == '_' || c == '~'
                    || c >= 0xA0 && c <= 0xD7FF || c >= 0xF900 && c <= 0xFDCF || c >= 0xFDF0
                    && c <= 0xFFEF) {
File Project Line
eu/fbk/knowledgestore/datastore/hbase/utils/AvroSerializer.java ks-server-hbase 245
eu/fbk/knowledgestore/runtime/SerializerAvro.java ks-server 251
        } else if (schema.equals(AvroSchemas.PLAIN_IDENTIFIER)) {
            final String string = record.get(0).toString();
            if (string.startsWith("_:")) {
                return this.factory.createBNode(string.substring(2));
            } else {
                return this.factory.createURI(string);
            }
        }
        throw new IllegalArgumentException("Unsupported encoded identifier: " + record);
    }

    private Literal decodeLiteral(final Object generic) {
        if (generic instanceof GenericRecord) {
            final GenericRecord record = (GenericRecord) generic;
            final Schema schema = record.getSchema();
            if (schema.equals(AvroSchemas.STRING_LANG)) {
File Project Line
eu/fbk/knowledgestore/datastore/hbase/utils/AvroSerializer.java ks-server-hbase 357
eu/fbk/knowledgestore/runtime/SerializerAvro.java ks-server 363
        return AvroSerializer.newGenericRecord(AvroSchemas.RECORD, encodedID, props);
    }

    private Object encodeValue(final Value value) {
        if (value instanceof Literal) {
            return encodeLiteral((Literal) value);
        } else if (value instanceof Resource) {
            return encodeIdentifier((Resource) value);
        } else {
            throw new IllegalArgumentException("Unsupported value: " + value);
        }
    }

    private Object encodeIdentifier(final Resource identifier) {
        if (identifier instanceof URI) {
            try {
                final Integer key = this.dictionary.keyFor((URI) identifier, false);
                if (key != null) {
                    return AvroSerializer.newGenericRecord(AvroSchemas.COMPRESSED_IDENTIFIER, key);
File Project Line
eu/fbk/knowledgestore/data/Data.java ks-core 529
eu/fbk/knowledgestore/data/Record.java ks-core 853
        final StringBuilder builder = new StringBuilder(16);
        int max = 52;
        for (int i = 0; i < bytes.length; ++i) {
            final int n = (bytes[i] & 0x7F) % max;
            if (n < 26) {
                builder.append((char) (65 + n));
            } else if (n < 52) {
                builder.append((char) (71 + n));
            } else {
                builder.append((char) (n - 4));
            }
            max = 62;
        }
        return builder.toString();
    }

Back to top

Last Published: 2016/02/08.

Reflow Maven skin by Andrius Velykis.

Data and Knowledge Management tools