@Override public Object getIndexProperty( String propertyName ) { return doc.get(name); }
public boolean hasProperty( Document document, Name propertyName ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties == null) { return false; } // Get the namespace container for the property name's namespace ... Document urlProps = properties.getDocument(propertyName.getNamespaceUri()); if (urlProps == null) { return false; } // Get the property ... Object fieldValue = urlProps.get(propertyName.getLocalName()); return !Null.matches(fieldValue); }
@Override public LinkedHashMap<String, Name> getChildrenMap() { LinkedHashMap<String, Name> children = new LinkedHashMap<String, Name>(); if (!federatedDocument.containsField(DocumentTranslator.CHILDREN)) { return children; } List<?> childrenArray = federatedDocument.getArray(DocumentTranslator.CHILDREN); for (Object child : childrenArray) { assert child instanceof Document; Document childDocument = (Document)child; String childId = translator.getKey(childDocument); Name childName = translator.getNameFactory().create(childDocument.get(DocumentTranslator.NAME)); children.put(childId, childName); } return children; }
@Override public Object getIndexProperty( String propertyName ) { return doc.get(name); }
public boolean hasProperty( Document document, Name propertyName ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties == null) { return false; } // Get the namespace container for the property name's namespace ... Document urlProps = properties.getDocument(propertyName.getNamespaceUri()); if (urlProps == null) { return false; } // Get the property ... Object fieldValue = urlProps.get(propertyName.getLocalName()); return !Null.matches(fieldValue); }
private String propertyAsString(Document document, String fieldName, String defaultValue) { Object value = document.get(fieldName); return value == null ? defaultValue : value.toString(); }
public Property getProperty( Document document, Name propertyName ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties == null) { return null; } // Get the namespace container for the property name's namespace ... Document urlProps = properties.getDocument(propertyName.getNamespaceUri()); if (urlProps == null) { return null; } // Get the property ... Object fieldValue = urlProps.get(propertyName.getLocalName()); return fieldValue == null ? null : propertyFor(propertyName, fieldValue); }
private boolean propertyAsBoolean(Document document, String propertyName, boolean defaultValue) { Object value = document.get(propertyName); if (value == null) { return defaultValue; } else if (value instanceof Boolean) { return (Boolean) value; } else { return Boolean.valueOf(value.toString()); } } }
protected void assertMatch( Document doc1, Document doc2 ) { assertEquals(doc1.size(), doc2.size()); for (Document.Field field1 : doc1.fields()) { if (field1.getValue() instanceof Document) { assertMatch(field1.getValueAsDocument(), doc2.getDocument(field1.getName())); } else { Object value2 = doc2.get(field1.getName()); assertEquals(field1.getValue(), value2); } } }
private int propertyAsInt(Document document, String propertyName, int defaultValue) { Object value = document.get(propertyName); if (value == null) { return defaultValue; } else if (value instanceof Number) { return ((Number) value).intValue(); } else { return Integer.valueOf(value.toString()); } }
@SuppressWarnings( "unchecked" ) private <Type> Type createJaasProvider() throws LoginException { Object value = this.document.get(FieldName.JAAS_POLICY_NAME); String policyName = value instanceof String ? value.toString() : Default.JAAS_POLICY_NAME; return (Type)new JaasProvider(policyName); }
@SuppressWarnings( "unchecked" ) private <Type> Type createAnonymousProvider() { Object roles = this.document.get(FieldName.ANONYMOUS_ROLES); Set<String> roleNames = new HashSet<String>(); if (roles instanceof Array) { Array roleValues = (Array)roles; for (Object roleName : roleValues) { if (roleName instanceof String) { roleNames.add(roleName.toString()); } } } Object usernameValue = this.document.get(FieldName.ANONYMOUS_USERNAME); String username = usernameValue instanceof String ? usernameValue.toString() : Default.ANONYMOUS_USERNAME; return (Type)new AnonymousProvider(username, roleNames); }
@SuppressWarnings( "unchecked" ) private <Type> Type createJaasProvider() throws LoginException { Object value = this.document.get(FieldName.JAAS_POLICY_NAME); String policyName = value instanceof String ? value.toString() : Default.JAAS_POLICY_NAME; return (Type)new JaasProvider(policyName); }
/** * Gets property value. * * @param name property name. * @return property value. */ public Object get(String name) { Object obj = document.get(name); return (obj instanceof BasicArray) ? ((BasicArray)obj).toArray() : obj; }
@Override public void run() { try { ByteArrayInputStream input = new ByteArrayInputStream(bsonBytes); Document doc = bsonReader.read(input); doc.get(key); } catch (Exception t) { error.compareAndSet(null, t); } } });
@Override public void run() { try { Document doc = reader.read(testData, introspectStringValues); if (getValue) doc.get(key); } catch (Exception t) { error.compareAndSet(null, t); } } });
protected void addValidatorsForDisallowedTypes( Document parent, Path parentPath, Problems problems, CompositeValidator validators ) { Object disallowed = parent.get("disallowed"); if (Null.matches(disallowed)) return; String requiredName = parentPath.getLast(); if (requiredName != null) { EnumSet<Type> disallowedTypes = Type.typesWithNames(disallowed); validators.add(new DisallowedTypesValidator(requiredName, disallowedTypes)); } }
protected void addValidatorsForDisallowedTypes( Document parent, Path parentPath, Problems problems, CompositeValidator validators ) { Object disallowed = parent.get("disallowed"); if (Null.matches(disallowed)) return; String requiredName = parentPath.getLast(); if (requiredName != null) { EnumSet<Type> disallowedTypes = Type.typesWithNames(disallowed); validators.add(new DisallowedTypesValidator(requiredName, disallowedTypes)); } }
protected void assertField( String name, Object value ) { Object actual = doc.get(name); if (value == null) { assertNull(actual); } else { assertEquals(value, actual); } }
protected void assertField( String name, Object value ) { Object actual = bson.get(name); if (value == null) { assertTrue(Null.matches(actual)); } else { assertEquals(value, actual); } } }