KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > model > plugin > PluginAttribute


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.model.plugin;
12
13 import org.eclipse.core.runtime.*;
14 import org.eclipse.pde.core.plugin.*;
15 import org.eclipse.pde.internal.ui.model.*;
16
17 public class PluginAttribute extends PluginObjectNode
18         implements
19             IPluginAttribute , IDocumentAttribute{
20     
21     private static final long serialVersionUID = 1L;
22
23     private IDocumentNode fEnclosingElement;
24     private String JavaDoc fValue;
25     private int fNameOffset = -1;
26     private int fNameLength = -1;
27     private int fValueOffset = -1;
28     private int fValueLength = -1;
29     
30     /* (non-Javadoc)
31      * @see org.eclipse.pde.core.plugin.IPluginAttribute#getValue()
32      */

33     public String JavaDoc getValue() {
34         return fValue;
35     }
36     /* (non-Javadoc)
37      * @see org.eclipse.pde.core.plugin.IPluginAttribute#setValue(java.lang.String)
38      */

39     public void setValue(String JavaDoc value) throws CoreException {
40         fValue = value;
41     }
42     /* (non-Javadoc)
43      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#setEnclosingElement(org.eclipse.pde.internal.ui.model.IDocumentNode)
44      */

45     public void setEnclosingElement(IDocumentNode node) {
46         fEnclosingElement = node;
47     }
48     /* (non-Javadoc)
49      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#getEnclosingElement()
50      */

51     public IDocumentNode getEnclosingElement() {
52         return fEnclosingElement;
53     }
54     /* (non-Javadoc)
55      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#setNameOffset(int)
56      */

57     public void setNameOffset(int offset) {
58         fNameOffset = offset;
59     }
60     /* (non-Javadoc)
61      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#getNameOffset()
62      */

63     public int getNameOffset() {
64         return fNameOffset;
65     }
66     /* (non-Javadoc)
67      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#setNameLength(int)
68      */

69     public void setNameLength(int length) {
70         fNameLength = length;
71     }
72     /* (non-Javadoc)
73      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#getNameLength()
74      */

75     public int getNameLength() {
76         return fNameLength;
77     }
78     /* (non-Javadoc)
79      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#setValueOffset(int)
80      */

81     public void setValueOffset(int offset) {
82         fValueOffset = offset;
83     }
84     /* (non-Javadoc)
85      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#getValueOffset()
86      */

87     public int getValueOffset() {
88         return fValueOffset;
89     }
90     /* (non-Javadoc)
91      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#setValueLength(int)
92      */

93     public void setValueLength(int length) {
94         fValueLength = length;
95     }
96     /* (non-Javadoc)
97      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#getValueLength()
98      */

99     public int getValueLength() {
100         return fValueLength;
101     }
102     /* (non-Javadoc)
103      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#getAttributeName()
104      */

105     public String JavaDoc getAttributeName() {
106         return getName();
107     }
108     /* (non-Javadoc)
109      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#getAttributeValue()
110      */

111     public String JavaDoc getAttributeValue() {
112         return getValue();
113     }
114     
115     /* (non-Javadoc)
116      * @see org.eclipse.pde.internal.ui.model.IDocumentAttribute#write()
117      */

118     public String JavaDoc write() {
119         return getName() + "=\"" + getWritableString(getValue()) + "\""; //$NON-NLS-1$ //$NON-NLS-2$
120
}
121
122     public String JavaDoc getWritableString(String JavaDoc source) {
123         return super
124                 .getWritableString(source)
125                 .replaceAll("\\r", "
") //$NON-NLS-1$ //$NON-NLS-2$
126
.replaceAll("\\n", "
"); //$NON-NLS-1$ //$NON-NLS-2$
127
}
128     
129 }
130
Popular Tags