Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordeboer2007-09-06 14:03:25 +0000
committerdeboer2007-09-06 14:03:25 +0000
commitcc79c1eb0f5ba56d4fe6a56fe996e36579e15331 (patch)
tree436888fd1a10127167768c282f902aa193da6468 /plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet
parent80b80b089b9633925a0903785727fcd0e7c1bc98 (diff)
downloadwebtools.servertools-cc79c1eb0f5ba56d4fe6a56fe996e36579e15331.tar.gz
webtools.servertools-cc79c1eb0f5ba56d4fe6a56fe996e36579e15331.tar.xz
webtools.servertools-cc79c1eb0f5ba56d4fe6a56fe996e36579e15331.zip
[202449] Cleanup IMemento/XMLMemento pairs
Diffstat (limited to 'plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet')
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IMemento.java78
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java111
2 files changed, 6 insertions, 183 deletions
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IMemento.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IMemento.java
index 3a04ab920..6be5f28da 100644
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IMemento.java
+++ b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IMemento.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,8 +9,6 @@
* IBM Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.util.List;
/**
* Interface to a memento used for saving the important state of an object
* in a form that can be persisted in the file system.
@@ -40,14 +38,6 @@ import java.util.List;
*/
public interface IMemento {
/**
- * Special reserved key used to store the memento id
- * (value <code>"org.eclipse.ui.id"</code>).
- *
- * @see #getId
- */
- public static final String TAG_ID = "IMemento.internal.id"; //$NON-NLS-1$
-
- /**
* Creates a new child of this memento with the given type.
* <p>
* The <code>getChild</code> and <code>getChildren</code> methods
@@ -62,22 +52,6 @@ public interface IMemento {
public IMemento createChild(String type);
/**
- * Creates a new child of this memento with the given type and id.
- * The id is stored in the child memento (using a special reserved
- * key, <code>TAG_ID</code>) and can be retrieved using <code>getId</code>.
- * <p>
- * The <code>getChild</code> and <code>getChildren</code> methods
- * are used to retrieve children of a given type.
- * </p>
- *
- * @param type the type
- * @param id the child id
- * @return a new child memento with the given type and id
- * @see #getId
- */
- public IMemento createChild(String type, String id);
-
- /**
* Returns the first child with the given type id.
*
* @param type the type id
@@ -92,31 +66,6 @@ public interface IMemento {
* @return the list of children with the given type
*/
public IMemento[] getChildren(String type);
-
- /**
- * Returns the floating point value of the given key.
- *
- * @param key the key
- * @return the value, or <code>null</code> if the key was not found or was found
- * but was not a floating point number
- */
- public Float getFloat(String key);
-
- /**
- * Returns the id for this memento.
- *
- * @return the memento id, or <code>null</code> if none
- * @see #createChild(java.lang.String,java.lang.String)
- */
- public String getId();
-
- /**
- * Returns the name for this memento.
- *
- * @return the memento name, or <code>null</code> if none
- * @see #createChild(java.lang.String,java.lang.String)
- */
- public String getName();
/**
* Returns the integer value of the given key.
@@ -144,22 +93,7 @@ public interface IMemento {
* but was not a boolean
*/
public Boolean getBoolean(String key);
-
- /**
- * Returns a list of all the names in this memento.
- *
- * @return a list of names
- */
- public List getNames();
-
- /**
- * Sets the value of the given key to the given floating point number.
- *
- * @param key the key
- * @param value the value
- */
- public void putFloat(String key, float value);
-
+
/**
* Sets the value of the given key to the given integer.
*
@@ -177,14 +111,6 @@ public interface IMemento {
public void putBoolean(String key, boolean value);
/**
- * Copy the attributes and children from <code>memento</code>
- * to the receiver.
- *
- * @param memento the IMemento to be copied.
- */
- public void putMemento(IMemento memento);
-
- /**
* Sets the value of the given key to the given string.
*
* @param key the key
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java
index e45d9c27e..8cbf23149 100644
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java
+++ b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * Copyright (c) 2003, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,7 +33,7 @@ import javax.xml.transform.stream.StreamResult;
* ObjectOutputStream, DataOutputStream, or Hashtable. However
* all of these approaches fail to meet the second requirement.
*
- * Memento supports binary persistance with a version ID.
+ * Memento supports binary persistence with a version ID.
*/
public final class XMLMemento implements IMemento {
private Document factory;
@@ -59,20 +59,10 @@ public final class XMLMemento implements IMemento {
}
/**
- * @see IMemento#createChild(String, String)
- */
- public IMemento createChild(String type, String id) {
- Element child = factory.createElement(type);
- child.setAttribute(TAG_ID, id);
- element.appendChild(child);
- return new XMLMemento(factory, child);
- }
-
- /**
* Create a Document from a Reader and answer a root memento for reading
* a document.
*/
- protected static XMLMemento createReadRoot(InputStream in) {
+ private static XMLMemento createReadRoot(InputStream in) {
Document document = null;
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
@@ -170,47 +160,6 @@ public final class XMLMemento implements IMemento {
}
/**
- * Returns an input stream for writing to the disk with a local locale.
- *
- * @return the input stream
- * @throws IOException
- */
- public InputStream getInputStream() throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- save(out);
- return new ByteArrayInputStream(out.toByteArray());
- }
-
- /**
- * @see IMemento#getFloat(String)
- */
- public Float getFloat(String key) {
- Attr attr = element.getAttributeNode(key);
- if (attr == null)
- return null;
- String strValue = attr.getValue();
- try {
- return new Float(strValue);
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- /**
- * @see IMemento#getId()
- */
- public String getId() {
- return element.getAttribute(TAG_ID);
- }
-
- /**
- * @see IMemento#getName()
- */
- public String getName() {
- return element.getNodeName();
- }
-
- /**
* @see IMemento#getInteger(String)
*/
public Integer getInteger(String key) {
@@ -234,21 +183,6 @@ public final class XMLMemento implements IMemento {
return null;
return attr.getValue();
}
-
- /**
- * @see IMemento#getNames()
- */
- public List<String> getNames() {
- NamedNodeMap map = element.getAttributes();
- int size = map.getLength();
- List<String> list = new ArrayList<String>();
- for (int i = 0; i < size; i++) {
- Node node = map.item(i);
- String name = node.getNodeName();
- list.add(name);
- }
- return list;
- }
/**
* Loads a memento from the given filename.
@@ -260,35 +194,6 @@ public final class XMLMemento implements IMemento {
return createReadRoot(in);
}
- /*
- * @see IMemento
- */
- private void putElement(Element element2) {
- NamedNodeMap nodeMap = element2.getAttributes();
- int size = nodeMap.getLength();
- for (int i = 0; i < size; i++){
- Attr attr = (Attr)nodeMap.item(i);
- putString(attr.getName(),attr.getValue());
- }
-
- NodeList nodes = element2.getChildNodes();
- size = nodes.getLength();
- for (int i = 0; i < size; i ++) {
- Node node = nodes.item(i);
- if (node instanceof Element) {
- XMLMemento child = (XMLMemento)createChild(node.getNodeName());
- child.putElement((Element)node);
- }
- }
- }
-
- /**
- * @see IMemento#putFloat(String, float)
- */
- public void putFloat(String key, float f) {
- element.setAttribute(key, String.valueOf(f));
- }
-
/**
* @see IMemento#putInteger(String, int)
*/
@@ -297,14 +202,6 @@ public final class XMLMemento implements IMemento {
}
/**
- * @see IMemento#putMemento(IMemento)
- */
- public void putMemento(IMemento memento) {
- XMLMemento xmlMemento = (XMLMemento) memento;
- putElement(xmlMemento.element);
- }
-
- /**
* @see IMemento#putString(String, String)
*/
public void putString(String key, String value) {
@@ -319,7 +216,7 @@ public final class XMLMemento implements IMemento {
* @param os
* @throws IOException
*/
- public void save(OutputStream os) throws IOException {
+ private void save(OutputStream os) throws IOException {
Result result = new StreamResult(os);
Source source = new DOMSource(factory);
try {

Back to the top