1 11 package org.eclipse.pde.internal.core.text.plugin; 12 13 import java.io.PrintWriter ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.pde.core.plugin.IPluginAttribute; 17 import org.eclipse.pde.core.plugin.ISharedPluginModel; 18 import org.eclipse.pde.internal.core.ischema.ISchema; 19 import org.eclipse.pde.internal.core.text.IDocumentAttribute; 20 import org.eclipse.pde.internal.core.text.IDocumentNode; 21 22 public class PluginAttribute extends PluginObjectNode implements 23 IPluginAttribute, IDocumentAttribute { 24 25 private static final long serialVersionUID = 1L; 26 27 private transient IDocumentNode fEnclosingElement; 28 private transient int fNameOffset = -1; 29 private transient int fNameLength = -1; 30 private transient int fValueOffset = -1; 31 private transient int fValueLength = -1; 32 33 private String fValue; 34 35 38 public String getValue() { 39 return fValue; 40 } 41 44 public void setValue(String value) throws CoreException { 45 fValue = value; 46 } 47 50 public void setEnclosingElement(IDocumentNode node) { 51 fEnclosingElement = node; 52 } 53 56 public IDocumentNode getEnclosingElement() { 57 return fEnclosingElement; 58 } 59 62 public void setNameOffset(int offset) { 63 fNameOffset = offset; 64 } 65 68 public int getNameOffset() { 69 return fNameOffset; 70 } 71 74 public void setNameLength(int length) { 75 fNameLength = length; 76 } 77 80 public int getNameLength() { 81 return fNameLength; 82 } 83 86 public void setValueOffset(int offset) { 87 fValueOffset = offset; 88 } 89 92 public int getValueOffset() { 93 return fValueOffset; 94 } 95 98 public void setValueLength(int length) { 99 fValueLength = length; 100 } 101 104 public int getValueLength() { 105 return fValueLength; 106 } 107 110 public String getAttributeName() { 111 return getName(); 112 } 113 116 public String getAttributeValue() { 117 return getValue(); 118 } 119 120 123 public String write() { 124 return getName() + "=\"" + getWritableString(getValue()) + "\""; } 126 127 public String getWritableString(String source) { 128 return super 129 .getWritableString(source) 130 .replaceAll("\\r", "
") .replaceAll("\\n", "
"); } 133 134 public void setAttributeName(String name) throws CoreException { 135 setName(name); 136 } 137 138 public void setAttributeValue(String value) throws CoreException { 139 setValue(value); 140 } 141 142 145 public void reconnect(ISharedPluginModel model, ISchema schema, IDocumentNode parent) { 146 super.reconnect(model, schema, parent); 147 fEnclosingElement = parent; 152 fNameLength = -1; 154 fNameOffset = -1; 156 fValueLength = -1; 158 fValueOffset = -1; 160 } 161 162 165 public void write(String indent, PrintWriter writer) { 166 writer.write(write()); 169 } 170 171 } 172 | Popular Tags |