1 22 23 package org.xquark.mapper.mapping; 24 25 import java.util.List ; 26 27 import org.xquark.schema.ElementDeclaration; 28 import org.xquark.schema.SchemaContext; 29 import org.xquark.xpath.NodeKind; 30 import org.xquark.xpath.PathExpr; 31 import org.xquark.xpath.XNode; 32 33 42 public class MappingContext extends SchemaContext 43 implements MappingLocator 44 { 45 private static final String RCSRevision = "$Revision: 1.1 $"; 46 private static final String RCSName = "$Name: $"; 47 48 52 54 protected MappingFactory factory; 55 protected MappingNode wNode; 56 protected XNode pattern = new XNode(); 57 58 62 public MappingContext(MappingFactory factory) 63 { 64 super(factory.getSchemaManager()); 65 this.factory = factory; 66 wNode = (MappingNode)factory.getTree().getRoot(); 67 } 68 69 74 public List currentTableMappings() 75 { 76 return wNode.getTableMappings(); 77 } 78 79 81 public List currentColumnMappings() 82 { 83 return wNode.getColumnMappings(); 84 } 85 86 88 public List getElementTableMappings(String namespace, String localName) 89 { 90 pattern.set(namespace, localName, NodeKind.ELEMENT); 91 MappingNode node = (MappingNode)wNode.getChild(pattern); 92 if (node == null) 93 return null; 94 else 95 return node.getTableMappings(); 96 } 97 98 100 public List getElementColumnMappings(String namespace, String localName) 101 { 102 pattern.set(namespace, localName, NodeKind.ELEMENT); 103 MappingNode node = (MappingNode)wNode.getChild(pattern); 104 if (node == null) 105 return null; else 107 return node.getColumnMappings(); 108 } 109 110 112 public List getAttributeTableMappings(String namespace, String localName) 113 { 114 pattern.set(namespace, localName, NodeKind.ATTRIBUTE); 115 MappingNode node = (MappingNode)wNode.getChild(pattern); 116 if (node == null) 117 return null; else 119 return node.getTableMappings(); 120 } 121 122 124 public List getAttributeColumnMappings(String namespace, String localName) 125 { 126 pattern.set(namespace, localName, NodeKind.ATTRIBUTE); 127 MappingNode node = (MappingNode)wNode.getChild(pattern); 128 if (node == null) 129 return null; else 131 return node.getColumnMappings(); 132 } 133 134 138 public final void push(ElementDeclaration decl) 139 { 140 super.push(decl); 141 pattern.set(decl.getNamespace(), decl.getName(), NodeKind.ELEMENT); 142 wNode = (MappingNode)wNode.getChild(pattern); 143 } 144 145 public final ElementDeclaration pop() 146 { 147 ElementDeclaration ret = super.pop(); 148 wNode = (MappingNode)wNode.getParent(); 149 return ret; 150 } 151 152 153 156 public PathExpr getLocation() 157 { 158 return wNode.getLocation(); 159 } 160 161 } 162 | Popular Tags |