/** * Valued constructor, accepts all elements containing the given property. * * @param property property, containing of key and value */ public ByProperty(Property property) { this(property.getKey(), property.getValue()); }
/** * Valued constructor, accepts all elements containing the given property. * * @param property property, containing of key and value */ public ByProperty(Property property) { this(property.getKey(), property.getValue()); }
/** * Returns the property meta data string for the specified property. The string consists of the * property key and the property value type, e.g. "foo:int". * * @param property property * @return property meta data */ public static String getPropertyMetaData(Property property) { return String.format("%s%s%s", property.getKey(), PROPERTY_TOKEN_DELIMITER, getTypeString(property.getValue())); }
/** * Returns the property meta data string for the specified property. The string consists of the * property key and the property value type, e.g. "foo:int". * * @param property property * @return property meta data */ public static String getPropertyMetaData(Property property) { return String.format("%s%s%s", property.getKey(), PROPERTY_TOKEN_DELIMITER, getTypeString(property.getValue())); }
/** * Sets the given property. If a property with the same property key already * exists, it will be replaced by the given property. * * @param property property */ public void set(Property property) { set(property.getKey(), property.getValue()); }
/** * Returns the property meta data string for the specified property. The string consists of the * property key and the property value type, e.g. "foo:int". * * @param property property * @return property meta data */ public static String getPropertyMetaData(Property property) { return String.format("%s%s%s", StringEscaper.escape(property.getKey(), CSVConstants.ESCAPED_CHARACTERS), MetaData.PROPERTY_TOKEN_DELIMITER, MetaData.getTypeString(property.getValue())); // no need to escape }
@Override public Put writeProperty(final Put put, Property property) { byte[] type = PropertyValueUtils.Bytes.getTypeByte(property.getValue()); byte[] bytesWithoutType = PropertyValueUtils.Bytes.getRawBytesWithoutType(property.getValue()); put.addColumn(CF_PROPERTY_TYPE_BYTES, Bytes.toBytes(property.getKey()), type); put.addColumn(CF_PROPERTY_VALUE_BYTES, Bytes.toBytes(property.getKey()), bytesWithoutType); return put; }
/** * Returns the property meta data string for the specified property. The string consists of the * property key and the property value type, e.g. "foo:int". * * @param property property * @return property meta data */ public static String getPropertyMetaData(Property property) { return String.format("%s%s%s", StringEscaper.escape(property.getKey(), CSVConstants.ESCAPED_CHARACTERS), MetaData.PROPERTY_TOKEN_DELIMITER, MetaData.getTypeString(property.getValue())); // no need to escape }
@Override public void flatMap(T value, Collector<Tuple2<String, Set<PropertyValue>>> out) throws Exception { if (value.getProperties() != null) { for (Property property : value.getProperties()) { reuseTuple.f0 = property.getKey(); reuseTuple.f1 = Sets.newHashSet(property.getValue()); out.collect(reuseTuple); } } } }
@Override public void flatMap(T value, Collector<Tuple2<String, Set<PropertyValue>>> out) throws Exception { if (value.getProperties() != null) { for (Property property : value.getProperties()) { reuseTuple.f0 = property.getKey(); reuseTuple.f1 = Sets.newHashSet(property.getValue()); out.collect(reuseTuple); } } } }
.append(escapeHtml4(property.getKey())) .append("</td><td>") .append(escapeHtml4(property.getValue().toString())) .append("</td></tr>");
.append(escapeHtml4(property.getKey())) .append("</td><td>") .append(escapeHtml4(property.getValue().toString())) .append("</td></tr>");
/** * Returns this property as a GDL formatted String. * * @param property The property. * @return A GDL formatted string that represents the property. */ private String propertyToGDLString(Property property) { StringBuilder result = new StringBuilder() .append(property.getKey()) .append(KEY_VALUE_SEPARATOR); PropertyValue value = property.getValue(); if (value.isString()) { result.append(STRING_PREFIX).append(value.toString()).append(STRING_SUFFIX); } else if (value.isNull()) { result.append(NULL_STRING); } else if (value.isDouble()) { result.append(value.toString()).append(DOUBLE_SUFFIX); } else if (value.isFloat()) { result.append(value.toString()).append(FLOAT_SUFFIX); } else if (value.isLong()) { result.append(value.toString()).append(LONG_SUFFIX); } else { result.append(value.toString()); } return result.toString(); } }
/** * Returns this property as a GDL formatted String. * * @param property The property. * @return A GDL formatted string that represents the property. */ private String propertyToGDLString(Property property) { StringBuilder result = new StringBuilder() .append(property.getKey()) .append(KEY_VALUE_SEPARATOR); PropertyValue value = property.getValue(); if (value.isString()) { result.append(STRING_PREFIX).append(value.toString()).append(STRING_SUFFIX); } else if (value.isNull()) { result.append(NULL_STRING); } else if (value.isDouble()) { result.append(value.toString()).append(DOUBLE_SUFFIX); } else if (value.isFloat()) { result.append(value.toString()).append(FLOAT_SUFFIX); } else if (value.isLong()) { result.append(value.toString()).append(LONG_SUFFIX); } else { result.append(value.toString()); } return result.toString(); } }
@Override public void flatMap(T value, Collector<Tuple2<Tuple2<String, String>, Set<PropertyValue>>> out) throws Exception { if (value.getProperties() != null) { for (Property property : value.getProperties()) { reuseTuple.f0.f0 = value.getLabel(); reuseTuple.f0.f1 = property.getKey(); reuseTuple.f1 = Sets.newHashSet(property.getValue()); out.collect(reuseTuple); } } } }
@Override public void flatMap(T value, Collector<Tuple2<Tuple2<String, String>, Set<PropertyValue>>> out) throws Exception { if (value.getProperties() != null) { for (Property property : value.getProperties()) { reuseTuple.f0.f0 = value.getLabel(); reuseTuple.f0.f1 = property.getKey(); reuseTuple.f1 = Sets.newHashSet(property.getValue()); out.collect(reuseTuple); } } } }
@Test public void testGetValue() throws Exception { PropertyValue propertyValue = PropertyValue.create(10); Property p = new Property("key", propertyValue); assertEquals(propertyValue, p.getValue()); }
@Test public void testIterator() throws Exception { Properties properties = Properties.createFromMap(SUPPORTED_PROPERTIES); for (Property property : properties) { assertTrue(SUPPORTED_PROPERTIES.containsKey(property.getKey())); assertEquals(SUPPORTED_PROPERTIES.get(property.getKey()), property.getValue().getObject()); } }
@Test public void testSetValue() throws Exception { PropertyValue propertyValue = PropertyValue.create(10); Property p = new Property("key", PropertyValue.create(11)); p.setValue(propertyValue); assertEquals(propertyValue, p.getValue()); }