List of usage examples for java.util Map containsValue
boolean containsValue(Object value);
From source file:org.atemsource.atem.impl.common.attribute.MapAttributeImpl.java
@Override public boolean containsValue(Object entity, J element) { Map map = getValue(entity); return map.containsValue(element); }
From source file:edu.cornell.mannlib.vitro.webapp.sparql.GetAllPrefix.java
private void addPrefixIfNecessary(String prefix, String namespace, Map<String, String> prefixMap) { if (!prefixMap.containsValue(namespace)) { prefixMap.put(prefix, namespace); }/* ww w .j a va 2s . c om*/ }
From source file:com.liferay.ci.jenkins.cache.LiferayJenkinsBuildCache.java
public boolean containsValue(String portletId, Object value) { if (!_buildsCache.containsKey(portletId)) { _buildsCache.put(portletId, new HashMap<String, JSONArray>()); }//from www . j a v a2 s .co m Map<String, JSONArray> portletCache = _getPortletCache(portletId); return portletCache.containsValue(value); }
From source file:Main.java
protected static String nodeToString(Node node, Set<String> parentPrefixes, String namespaceURI) throws Exception { StringBuilder b = new StringBuilder(); if (node == null) { return ""; }/*from ww w .j ava 2 s .c o m*/ if (node instanceof Element) { Element element = (Element) node; b.append("<"); b.append(element.getNodeName()); Map<String, String> thisLevelPrefixes = new HashMap(); if (element.getPrefix() != null && !parentPrefixes.contains(element.getPrefix())) { thisLevelPrefixes.put(element.getPrefix(), element.getNamespaceURI()); } if (element.hasAttributes()) { NamedNodeMap map = element.getAttributes(); for (int i = 0; i < map.getLength(); i++) { Node attr = map.item(i); if (attr.getNodeName().startsWith("xmlns")) continue; if (attr.getPrefix() != null && !parentPrefixes.contains(attr.getPrefix())) { thisLevelPrefixes.put(attr.getPrefix(), element.getNamespaceURI()); } b.append(" "); b.append(attr.getNodeName()); b.append("=\""); b.append(attr.getNodeValue()); b.append("\""); } } if (namespaceURI != null && !thisLevelPrefixes.containsValue(namespaceURI) && !namespaceURI.equals(element.getParentNode().getNamespaceURI())) { b.append(" xmlns=\"").append(namespaceURI).append("\""); } for (Map.Entry<String, String> entry : thisLevelPrefixes.entrySet()) { b.append(" xmlns:").append(entry.getKey()).append("=\"").append(entry.getValue()).append("\""); parentPrefixes.add(entry.getKey()); } NodeList children = element.getChildNodes(); boolean hasOnlyAttributes = true; for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() != Node.ATTRIBUTE_NODE) { hasOnlyAttributes = false; break; } } if (!hasOnlyAttributes) { b.append(">"); for (int i = 0; i < children.getLength(); i++) { b.append(nodeToString(children.item(i), parentPrefixes, children.item(i).getNamespaceURI())); } b.append("</"); b.append(element.getNodeName()); b.append(">"); } else { b.append("/>"); } for (String thisLevelPrefix : thisLevelPrefixes.keySet()) { parentPrefixes.remove(thisLevelPrefix); } } else if (node.getNodeValue() != null) { b.append(encodeText(node.getNodeValue())); } return b.toString(); }
From source file:Main.java
protected static String nodeToString(Node node, Set<String> parentPrefixes, String namespaceURI) throws Exception { StringBuilder b = new StringBuilder(); if (node == null) { return ""; }//from ww w . j av a2s .c o m if (node instanceof Element) { Element element = (Element) node; b.append("<"); b.append(element.getNodeName()); Map<String, String> thisLevelPrefixes = new HashMap(); if (element.getPrefix() != null && !parentPrefixes.contains(element.getPrefix())) { thisLevelPrefixes.put(element.getPrefix(), element.getNamespaceURI()); } if (element.hasAttributes()) { NamedNodeMap map = element.getAttributes(); for (int i = 0; i < map.getLength(); i++) { Node attr = map.item(i); if (attr.getNodeName().startsWith("xmlns")) continue; if (attr.getPrefix() != null && !parentPrefixes.contains(attr.getPrefix())) { thisLevelPrefixes.put(attr.getPrefix(), element.getNamespaceURI()); } b.append(" "); b.append(attr.getNodeName()); b.append("=\""); b.append(attr.getNodeValue()); b.append("\""); } } if (namespaceURI != null && !thisLevelPrefixes.containsValue(namespaceURI) && !namespaceURI.equals(element.getParentNode().getNamespaceURI())) { b.append(" xmlns=\"").append(namespaceURI).append("\""); } for (Map.Entry<String, String> entry : thisLevelPrefixes.entrySet()) { b.append(" xmlns:").append(entry.getKey()).append("=\"").append(entry.getValue()).append("\""); parentPrefixes.add(entry.getKey()); } NodeList children = element.getChildNodes(); boolean hasOnlyAttributes = true; for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() != Node.ATTRIBUTE_NODE) { hasOnlyAttributes = false; break; } } if (!hasOnlyAttributes) { b.append(">"); for (int i = 0; i < children.getLength(); i++) { b.append(nodeToString(children.item(i), parentPrefixes, children.item(i).getNamespaceURI())); } b.append("</"); b.append(element.getNodeName()); b.append(">"); } else { b.append("/>"); } for (String thisLevelPrefix : thisLevelPrefixes.keySet()) { parentPrefixes.remove(thisLevelPrefix); } } else if (node.getNodeValue() != null) { b.append(encodeText(node.getNodeValue(), node instanceof Attr)); } return b.toString(); }
From source file:Main.java
protected static String nodeToString(Node node, Set<String> parentPrefixes, String namespaceURI) throws Exception { StringBuilder b = new StringBuilder(); if (node == null) { return ""; }/* w w w. j av a2 s .c o m*/ if (node instanceof Element) { Element element = (Element) node; b.append("<"); b.append(element.getNodeName()); Map<String, String> thisLevelPrefixes = new HashMap(); if (element.getPrefix() != null && !parentPrefixes.contains(element.getPrefix())) { thisLevelPrefixes.put(element.getPrefix(), element.getNamespaceURI()); } if (element.hasAttributes()) { NamedNodeMap map = element.getAttributes(); for (int i = 0; i < map.getLength(); i++) { Node attr = map.item(i); if (attr.getNodeName().startsWith("xmlns")) continue; if (attr.getPrefix() != null && !parentPrefixes.contains(attr.getPrefix())) { thisLevelPrefixes.put(attr.getPrefix(), element.getNamespaceURI()); } b.append(" "); b.append(attr.getNodeName()); b.append("=\""); b.append(attr.getNodeValue()); b.append("\""); } } if (namespaceURI != null && !thisLevelPrefixes.containsValue(namespaceURI) && !namespaceURI.equals(element.getParentNode().getNamespaceURI())) { b.append(" xmlns=\"").append(namespaceURI).append("\""); } for (Map.Entry<String, String> entry : thisLevelPrefixes.entrySet()) { b.append(" xmlns:").append(entry.getKey()).append("=\"").append(entry.getValue()).append("\""); parentPrefixes.add(entry.getKey()); } NodeList children = element.getChildNodes(); boolean hasOnlyAttributes = true; for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() != Node.ATTRIBUTE_NODE) { hasOnlyAttributes = false; break; } } if (!hasOnlyAttributes) { b.append(">"); for (int i = 0; i < children.getLength(); i++) { b.append(nodeToString(children.item(i), parentPrefixes, children.item(i).getNamespaceURI())); } b.append("</"); b.append(element.getNodeName()); b.append(">"); } else { b.append("/>"); } for (String thisLevelPrefix : thisLevelPrefixes.keySet()) { parentPrefixes.remove(thisLevelPrefix); } } else if (node.getNodeValue() != null) { b.append(encodeText(node.getNodeValue())); } return b.toString(); }
From source file:Main.java
protected static String nodeToString(Node node, Set<String> parentPrefixes, String namespaceURI) throws Exception { StringBuilder b = new StringBuilder(); if (node == null) { return ""; }/*from w w w .j a va 2 s . c om*/ if (node instanceof Element) { Element element = (Element) node; b.append("<"); b.append(element.getNodeName()); Map<String, String> thisLevelPrefixes = new HashMap(); if (element.getPrefix() != null && !parentPrefixes.contains(element.getPrefix())) { thisLevelPrefixes.put(element.getPrefix(), element.getNamespaceURI()); } if (element.hasAttributes()) { NamedNodeMap map = element.getAttributes(); for (int i = 0; i < map.getLength(); i++) { Node attr = map.item(i); if (attr.getNodeName().startsWith("xmlns")) continue; if (attr.getPrefix() != null && !parentPrefixes.contains(attr.getPrefix())) { thisLevelPrefixes.put(attr.getPrefix(), element.getNamespaceURI()); } b.append(" "); b.append(attr.getNodeName()); b.append("=\""); b.append(attr.getNodeValue()); b.append("\""); } } if (namespaceURI != null && !thisLevelPrefixes.containsValue(namespaceURI) && !namespaceURI.equals(element.getParentNode().getNamespaceURI())) { b.append(" xmlns=\"").append(namespaceURI).append("\""); } for (Map.Entry<String, String> entry : thisLevelPrefixes.entrySet()) { b.append(" xmlns:").append(entry.getKey()).append("=\"").append(entry.getValue()).append("\""); parentPrefixes.add(entry.getKey()); } NodeList children = element.getChildNodes(); boolean hasOnlyAttributes = true; for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeType() != Node.ATTRIBUTE_NODE) { hasOnlyAttributes = false; break; } } if (!hasOnlyAttributes) { b.append(">"); for (int i = 0; i < children.getLength(); i++) { b.append(nodeToString(children.item(i), parentPrefixes, children.item(i).getNamespaceURI())); } b.append("</"); b.append(element.getNodeName()); b.append(">"); } else { b.append("/>"); } for (String thisLevelPrefix : thisLevelPrefixes.keySet()) { parentPrefixes.remove(thisLevelPrefix); } } else if (node.getNodeValue() != null) { b.append(encodeText(node, node.getNodeValue())); } return b.toString(); }
From source file:eionet.cr.util.sesame.ResultCompareUtil.java
/** * * @param bs1// w ww . j ava2 s. c om * @param bs2 * @param bNodeMapping * @return */ private static boolean bindingSetsMatch(BindingSet bs1, BindingSet bs2, Map<BNode, BNode> bNodeMapping) { if (bs1.size() != bs2.size()) { return false; } for (Binding binding1 : bs1) { Value value1 = binding1.getValue(); Value value2 = bs2.getValue(binding1.getName()); if (value1 instanceof BNode && value2 instanceof BNode) { BNode mappedBNode = bNodeMapping.get(value1); if (mappedBNode != null) { // bNode 'value1' was already mapped to some other bNode if (!value2.equals(mappedBNode)) { // 'value1' and 'value2' do not match return false; } } else { // 'value1' was not yet mapped, we need to check if 'value2' is a // possible mapping candidate if (bNodeMapping.containsValue(value2)) { // 'value2' is already mapped to some other value. return false; } } } else { if (!StringUtils.equals(value1.stringValue(), value2.stringValue())) { return false; } // values are not (both) bNodes if (value1 instanceof Literal && value2 instanceof Literal) { // do literal value-based comparison for supported datatypes Literal leftLit = (Literal) value1; Literal rightLit = (Literal) value2; URI dt1 = leftLit.getDatatype(); URI dt2 = rightLit.getDatatype(); if (dt1 != null && dt2 != null && dt1.equals(dt2) && XMLDatatypeUtil.isValidValue(leftLit.getLabel(), dt1) && XMLDatatypeUtil.isValidValue(rightLit.getLabel(), dt2)) { Integer compareResult = null; if (dt1.equals(XMLSchema.DOUBLE)) { compareResult = Double.compare(leftLit.doubleValue(), rightLit.doubleValue()); } else if (dt1.equals(XMLSchema.FLOAT)) { compareResult = Float.compare(leftLit.floatValue(), rightLit.floatValue()); } else if (dt1.equals(XMLSchema.DECIMAL)) { compareResult = leftLit.decimalValue().compareTo(rightLit.decimalValue()); } else if (XMLDatatypeUtil.isIntegerDatatype(dt1)) { compareResult = leftLit.integerValue().compareTo(rightLit.integerValue()); } else if (dt1.equals(XMLSchema.BOOLEAN)) { Boolean leftBool = Boolean.valueOf(leftLit.booleanValue()); Boolean rightBool = Boolean.valueOf(rightLit.booleanValue()); compareResult = leftBool.compareTo(rightBool); } else if (XMLDatatypeUtil.isCalendarDatatype(dt1)) { XMLGregorianCalendar left = leftLit.calendarValue(); XMLGregorianCalendar right = rightLit.calendarValue(); compareResult = left.compare(right); } if (compareResult != null) { if (compareResult.intValue() != 0) { return false; } } else if (!value1.equals(value2)) { return false; } } else if (!value1.equals(value2)) { return false; } } else if (!value1.equals(value2)) { return false; } } } return true; }
From source file:org.talend.mdm.webapp.browserecords.server.ItemsBrowserDWR.java
private boolean resolvedInInheritanceMapping(String fkpath, String target, Map<String, String> inheritanceForeignKeyMap) { if (inheritanceForeignKeyMap.isEmpty() || !inheritanceForeignKeyMap.containsValue(target)) { return false; }//from w w w .j a va 2s. c o m for (Entry<String, String> current : inheritanceForeignKeyMap.entrySet()) { String fkName = StringUtils.substringAfterLast(fkpath, "/"); //$NON-NLS-1$ if (target.equals(current.getValue()) && current.getKey().endsWith(fkName)) { return true; } } return false; }
From source file:org.sindice.analytics.servlet.JsonResponseWriter.java
private void addClassAttributes(final ScoreLabel sug, final Map<String, Object> rec) { final ArrayList<Map<String, Object>> contexts = new ArrayList<Map<String, Object>>(); for (Label label : sug.getLabels()) { final String value = (String) label.getContext().get(QueryProcessor.CLASS_ATTRIBUTE_LABEL_VAR).get(0); final int count = Integer .valueOf(label.getContext().get(QueryProcessor.CLASS_ATTRIBUTE_CARD_VAR).get(0).toString()); if (contexts.isEmpty()) { // init final Map<String, Object> types = new HashMap<String, Object>(); types.put(ResponseStructure.VALUE, value); types.put(ResponseStructure.COUNT, count); contexts.add(types);//from ww w . ja va 2s .co m } else { boolean isPresent = false; for (Map<String, Object> ct : contexts) { if (ct.containsValue(value)) { isPresent = true; ct.put(ResponseStructure.COUNT, ((Integer) ct.get(ResponseStructure.COUNT)) + count); break; } } if (!isPresent) { // add the new class attribute final Map<String, Object> types = new HashMap<String, Object>(); types.put(ResponseStructure.VALUE, value); types.put(ResponseStructure.COUNT, count); contexts.add(types); } } } rec.put("class_attributes", contexts); }