@Override public Type getType() { if (fallback == null) { // TODO try to do something better - currently RemovedProperty is always a container if there's no fallback // Simulate a complex type return new ComplexTypeImpl(getSchema(), getSchema().getName(), fieldName); } return fallback.getType(); }
@Override public Property getProperty(String xpath) { if (xpath == null) { throw new PropertyNotFoundException("null", "Invalid null xpath"); } String cxpath = canonicalXPath(xpath); if (cxpath.isEmpty()) { throw new PropertyNotFoundException(xpath, "Schema not specified"); } String schemaName = getXPathSchemaName(cxpath, schemas, null); if (schemaName == null) { if (cxpath.indexOf(':') != -1) { throw new PropertyNotFoundException(xpath, "No such schema"); } else { throw new PropertyNotFoundException(xpath); } } DocumentPart part = getPart(schemaName); if (part == null) { throw new PropertyNotFoundException(xpath); } // cut prefix String partPath = cxpath.substring(cxpath.indexOf(':') + 1); try { return part.resolvePath(partPath); } catch (PropertyNotFoundException e) { throw new PropertyNotFoundException(xpath, e.getDetail()); } }
@Override @SuppressWarnings("unchecked") public Object convert(Object object) throws TypeException { if (object instanceof Map) { Map<Object, Object> map = (Map<Object, Object>) object; for (Entry<Object, Object> entry : map.entrySet()) { String key = entry.getKey().toString(); Field field = getField(key); if (field == null) { throw new IllegalArgumentException("Field " + key + " is not defined for the complex type " + getName()); } entry.setValue(field.getType().convert(entry.getValue())); } return object; } throw new TypeException("Incompatible object: " + object.getClass() + " for type " + this); }
@Override public Field addField(String name, Type type, String defaultValue, int flags, Collection<Constraint> constraints) { QName qname = QName.valueOf(name, ns.prefix); FieldImpl field = new FieldImpl(qname, this, type, defaultValue, flags, constraints); addField(field); return field; }
protected Type createFakeComplexType(Schema schema, ComplexType superType, String name, XSModelGroup mg) throws TypeBindingException { ComplexType ct = new ComplexTypeImpl(superType, schema.getName(), name); // -------- Workaround - we register now the complex type - to fix // recursive references to the same type schema.registerType(ct); return processModelGroup(schema, superType, name, ct, mg, false); }
throw new PropertyNotFoundException("null", "Invalid null xpath"); String cxpath = canonicalXPath(xpath); if (cxpath.isEmpty()) { throw new PropertyNotFoundException(xpath, "Schema not specified");
protected Type createComplexType(Schema schema, ComplexType superType, String name, XSContentType content, boolean abstractType) throws TypeBindingException { ComplexType ct = new ComplexTypeImpl(superType, schema.getName(), name); // -------- Workaround - we register now the complex type - to fix // recursive references to the same type schema.registerType(ct); // ------------------------------------------ XSParticle particle = content.asParticle(); if (particle == null) { // complex type without particle -> may be it contains only // attributes -> return it as is return ct; } XSTerm term = particle.getTerm(); XSModelGroup mg = term.asModelGroup(); return processModelGroup(schema, superType, name, ct, mg, abstractType); }
continue; s = canonicalXPath(s);