public Set entrySet() { if (entrySet == null) { entrySet = new LinkedHashSet<MapEntry>(); final Collection<PropertyDescriptor> types = feature.getType().getDescriptors(); Name attName; Map attributesMap; for (Iterator<PropertyDescriptor> iterator = types.iterator(); iterator.hasNext(); ) { attName = iterator.next().getName(); attributesMap = new AttributeMap(attName, feature); entrySet.add( new MapEntry<Object, Object>(attName.getLocalPart(), attributesMap)); } } return entrySet; } }
/** Returns the value corresponding to this entry, as a String. */ public Object getValue() { Object actualValue = super.getValue(); String stringValue = FeatureWrapper.valueToString(actualValue); return stringValue; } }
/** * Compares the specified object with this entry for equality. * * @param object The object to compare with this entry for equality. */ @Override public boolean equals(final Object object) { if (object instanceof Map.Entry) { final Map.Entry that = (Map.Entry) object; return Utilities.equals(this.getKey(), that.getKey()) && Utilities.equals(this.getValue(), that.getValue()); } return false; }
/** * Compares the specified object with this entry for equality. */ public boolean equals(final Object object) { if (object instanceof Map.Entry) { final Map.Entry that = (Map.Entry) object; return Utilities.equals(this.getKey(), that.getKey()) && Utilities.equals(this.getValue(), that.getValue()); } return false; }
/** * Compares the specified object with this entry for equality. * * @param object The object to compare with this entry for equality. */ @Override public boolean equals(final Object object) { if (object instanceof Map.Entry) { final Map.Entry that = (Map.Entry) object; return Utilities.equals(this.getKey(), that.getKey()) && Utilities.equals(this.getValue(), that.getValue()); } return false; }
new MapEntry<Object, Object>( "isComplex", property instanceof ComplexAttribute)); entrySet.add(new MapEntry<Object, Object>("name", attributeName.getLocalPart())); entrySet.add( new MapEntry<Object, Object>("namespace", getNamespace(attributeName))); entrySet.add(new MapEntry<Object, Object>("prefix", getPrefix(attributeName))); new MapEntry<Object, Object>( "type", buildType((ComplexType) attributeDescr.getType()))); } else { entrySet.add( new MapEntry<Object, Object>( "type", attributeDescr.getType().getBinding().getName())); Geometry.class.isAssignableFrom(attributeDescr.getType().getBinding()); entrySet.add( new MapEntry<Object, Object>("isGeometry", Boolean.valueOf(isGeometry))); entrySet.add(new MapEntry<Object, Object>("rawValue", rawValue));
/** Returns a set view of the mappings contained in this map. */ @Override public Set<Entry<String, Object>> entrySet() { if (entries == null) { entries = new HashSet<Entry<String, Object>>(Math.round(KEYS.length / 0.75f) + 1, 0.75f); for (int i = 0; i < KEYS.length; i++) { final Object value = get(i); if (value != null) { entries.add(new MapEntry<String, Object>(KEYS[i], value)); } } entries = Collections.unmodifiableSet(entries); } return entries; } }
/** * Set {@link #entry} to the next entry to iterate. Returns {@code true} if an entry has * been found, or {@code false} if the iteration is finished. */ @SuppressWarnings("unchecked") private boolean findNext() { while (iterator.hasNext()) { final Map.Entry<K, Object> candidate = iterator.next(); Object value = candidate.getValue(); if (value instanceof Reference) { value = ((Reference<K, V>) value).get(); entry = new MapEntry<K, V>( (K) SoftValueHashMap.resolveNull(candidate.getKey()), (V) value); return true; } if (value != null) { entry = new MapEntry<K, V>( (K) SoftValueHashMap.resolveNull(candidate.getKey()), (V) value); return true; } } return false; }
@Test public void testDecode03() { String qualifiedName = "s1___s2"; List<MapEntry<String, String>> decode = NCNameResourceCodec.decode(qualifiedName); assertEquals(2, decode.size()); assertEquals("s1_", decode.get(0).getKey()); assertEquals("s2", decode.get(0).getValue()); assertEquals("s1", decode.get(1).getKey()); assertEquals("_s2", decode.get(1).getValue()); }
/** * @return a List of possible workspace/name pairs, possibly empty if the input could not be * decoded; */ public static List<MapEntry<String, String>> decode(String qualifiedName) { int lastPos = qualifiedName.lastIndexOf(DELIMITER); List<MapEntry<String, String>> ret = new ArrayList<MapEntry<String, String>>(); if (lastPos == -1) { ret.add(new MapEntry<String, String>(null, qualifiedName)); return ret; } while (lastPos > -1) { String ws = qualifiedName.substring(0, lastPos); String name = qualifiedName.substring(lastPos + DELIMITER.length()); ret.add(new MapEntry<String, String>(ws, name)); lastPos = qualifiedName.lastIndexOf(DELIMITER, lastPos - 1); } return ret; } }
@Test public void testDecode02() { String qualifiedName = "s1__s2__s3"; List<MapEntry<String, String>> decode = NCNameResourceCodec.decode(qualifiedName); assertEquals(2, decode.size()); assertEquals("s1__s2", decode.get(0).getKey()); assertEquals("s3", decode.get(0).getValue()); assertEquals("s1", decode.get(1).getKey()); assertEquals("s2__s3", decode.get(1).getValue()); }
/** * @return a List of possible workspace/name pairs, possibly empty if the input could not be * decoded; */ public static List<MapEntry<String, String>> decode(String qualifiedName) { int lastPos = qualifiedName.lastIndexOf(DELIMITER); List<MapEntry<String, String>> ret = new ArrayList<MapEntry<String, String>>(); if (lastPos == -1) { ret.add(new MapEntry<String, String>(null, qualifiedName)); return ret; } while (lastPos > -1) { String ws = qualifiedName.substring(0, lastPos); String name = qualifiedName.substring(lastPos + DELIMITER.length()); ret.add(new MapEntry<String, String>(ws, name)); lastPos = qualifiedName.lastIndexOf(DELIMITER, lastPos - 1); } return ret; } }
/** * Set {@link #entry} to the next entry to iterate. Returns {@code true} if * an entry has been found, or {@code false} if the iteration is finished. */ private boolean findNext() { assert Thread.holdsLock(hash); while (iterator.hasNext()) { final Map.Entry candidate = (Map.Entry) iterator.next(); Object value = candidate.getValue(); if (value instanceof Reference) { value = ((Reference) value).get(); entry = new MapEntry(candidate.getKey(), value); return true; } if (value != null) { entry = candidate; return true; } } return false; }
@Test // (expected=IllegalArgumentException.class) public void testDecodeBad() { String qualifiedName = "bad_qualified_name"; List<MapEntry<String, String>> decode = NCNameResourceCodec.decode(qualifiedName); assertEquals(1, decode.size()); assertNull(decode.get(0).getKey()); assertEquals("bad_qualified_name", decode.get(0).getValue()); } }
/** * Set {@link #entry} to the next entry to iterate. Returns {@code true} if * an entry has been found, or {@code false} if the iteration is finished. */ @SuppressWarnings("unchecked") private boolean findNext() { assert Thread.holdsLock(hash); while (iterator.hasNext()) { final Map.Entry<K,Object> candidate = iterator.next(); Object value = candidate.getValue(); if (value instanceof Reference) { value = ((Reference) value).get(); entry = new MapEntry<K,V>(candidate.getKey(), (V) value); return true; } if (value != null) { entry = (Map.Entry<K,V>) candidate; return true; } } return false; }