1 17 18 package org.sape.carbon.core.config.node.link; 19 20 import org.sape.carbon.core.config.format.ConfigurationFormatException; 21 import org.sape.carbon.core.config.node.ConfigurationDocument; 22 import org.sape.carbon.core.config.node.Node; 23 import org.sape.carbon.core.config.node.NodeIOException; 24 import org.sape.carbon.core.config.node.NodeNotFoundException; 25 import org.sape.carbon.core.config.node.NodeRemovalException; 26 import org.sape.carbon.core.exception.InvalidParameterException; 27 28 46 public abstract class AbstractLinkNode implements LinkNode { 47 53 protected ConfigurationDocument linkConfigurationDocument; 54 55 60 protected Node targetNode; 61 62 71 public AbstractLinkNode( 72 ConfigurationDocument linkConfigurationDocument, 73 Node targetNode) { 74 75 if (linkConfigurationDocument == null) { 76 throw new InvalidParameterException( 77 this.getClass(), 78 "linkConfigurationDocument cannot be null"); 79 } 80 if (targetNode == null) { 81 throw new InvalidParameterException( 82 this.getClass(), 83 "targetNode cannot be null"); 84 } 85 86 this.linkConfigurationDocument = linkConfigurationDocument; 87 88 this.targetNode = targetNode; 89 } 90 91 94 public LinkNodeConfiguration readLinkConfiguration() 95 throws NodeIOException, ConfigurationFormatException { 96 97 return (LinkNodeConfiguration) 98 this.linkConfigurationDocument.readConfiguration(); 99 } 100 101 104 public void writeLinkConfiguration(LinkNodeConfiguration config) 105 throws NodeIOException, ConfigurationFormatException { 106 107 this.linkConfigurationDocument.writeConfiguration(config); 108 config.getLinkNodeFactoryClass(); 109 } 110 111 114 public String getName() { 115 return this.linkConfigurationDocument.getName(); 116 } 117 118 121 public String getAbsoluteName() { 122 return this.linkConfigurationDocument.getAbsoluteName(); 123 } 124 125 128 public boolean getAllowsChildren() { 129 return this.targetNode.getAllowsChildren(); 130 } 131 132 135 public int remove() throws NodeRemovalException { 136 return this.linkConfigurationDocument.remove(); 137 } 138 139 142 public Node getParent() { 143 return this.linkConfigurationDocument.getParent(); 144 } 145 146 151 public String toString() { 152 return getName(); 153 } 154 155 158 public boolean isRemoved() { 159 return (this.linkConfigurationDocument.isRemoved() 160 || this.targetNode.isRemoved()); 161 } 162 163 166 public void refresh() { 167 this.targetNode.refresh(); 168 } 169 170 173 public boolean containsChild(String childName) { 174 return targetNode.containsChild(childName); 175 } 176 177 180 public Node fetchChild(String childName) 181 throws NodeNotFoundException { 182 183 return targetNode.fetchChild(childName); 184 } 185 186 189 public Node[] fetchChildren() { 190 return targetNode.fetchChildren(); 191 } 192 193 } 194 | Popular Tags |