Skip to content

Commit

Permalink
Working on JAXB mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinSviridov committed Jul 13, 2015
1 parent dae8889 commit c7cd4bf
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ private ISchemaType generateType(JAXBType jaxbType, StructureType structureType)
return existing;
}
HashMap<String,String> namespaces = jaxbType.gatherNamespaces();
TypeModelImpl typeModel = new TypeModelImpl(xmlName,jaxbType.getClassName(),namespaces,structureType);
ISchemaType schemaType = getType(jaxbType,structureType,namespaces);
if(!(schemaType instanceof TypeModelImpl)){
return schemaType;
}
TypeModelImpl typeModel = (TypeModelImpl) schemaType;
this.jaxbTypeMap.put(xmlName, typeModel);
HashMap<String,String>prefixes=jaxbType.gatherNamespaces();

Expand Down Expand Up @@ -113,6 +117,11 @@ else if (p instanceof JAXBElementProperty){
private ISchemaType getType(JAXBProperty p) {

JAXBType propertyType = p.getType();
StructureType st = p.getStructureType();
return getType(propertyType, st, null);
}

private ISchemaType getType(JAXBType propertyType, StructureType st, HashMap<String, String> namespaces) {
String canonicalName = propertyType!=null ? propertyType.getClassName() : "java.lang.Object";

ISchemaType primitive = getPrimitiveType(canonicalName);
Expand All @@ -122,7 +131,8 @@ private ISchemaType getType(JAXBProperty p) {

TypeModelImpl type = this.javaTypeMap.get(canonicalName);
if(type==null){
type = new TypeModelImpl(canonicalName,canonicalName,null,false,p.getStructureType());
String xmlName = propertyType.getXMLName();
type = new TypeModelImpl(xmlName,canonicalName,namespaces,st);
this.javaTypeMap.put(canonicalName, type);
}
return type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ public interface ISchemaType {
String getClassQualifiedName();

StructureType getParentStructureType();

boolean isMapping();

ISchemaType getActualType();
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,14 @@ public String getClassQualifiedName() {
public StructureType getParentStructureType() {
return StructureType.COMMON;
}

@Override
public boolean isMapping() {
return false;
}

@Override
public ISchemaType getActualType() {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public TypeModelImpl(String name, String classQualifiedName, Map<String,String>
this.parentStructureType = parentStructureType;
}

public TypeModelImpl(String name, String classQualifiedName, Map<String,String> namespaces, boolean isSimple,StructureType parentStructureType) {
protected TypeModelImpl(String name, String classQualifiedName, Map<String,String> namespaces, boolean isSimple,StructureType parentStructureType) {
super();
this.name = name;
this.isSimple = isSimple;
Expand Down Expand Up @@ -102,4 +102,16 @@ public StructureType getParentStructureType() {
return this.parentStructureType;
}

@Override
public boolean isMapping() {
// TODO Auto-generated method stub
return false;
}

@Override
public ISchemaType getActualType() {
// TODO Auto-generated method stub
return null;
}

}

0 comments on commit c7cd4bf

Please sign in to comment.