Index: src/nongnu/cashews/commons/PairList.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/commons/PairList.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 PairList.java --- src/nongnu/cashews/commons/PairList.java 8 May 2005 12:03:41 -0000 1.1 +++ src/nongnu/cashews/commons/PairList.java 19 May 2005 10:26:34 -0000 @@ -36,6 +36,7 @@ public class PairList /** * Serialization ID. */ + private static final long serialVersionUID = -4098974544672379656L; /** * Constructs an empty PairList. Index: src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 RenameNodeCommand.java --- src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java 16 May 2005 14:22:13 -0000 1.3 +++ src/nongnu/cashews/eclipse/composer/commands/RenameNodeCommand.java 19 May 2005 10:26:34 -0000 @@ -39,6 +39,9 @@ package nongnu.cashews.eclipse.composer. import nongnu.cashews.eclipse.composer.model.Diagram; import nongnu.cashews.eclipse.composer.model.Node; +import nongnu.cashews.eclipse.composer.model.NodeRegistrar; +import static nongnu.cashews.eclipse.composer.util.Dialogs.displayErrorDialog; + import org.eclipse.gef.commands.Command; public class RenameNodeCommand @@ -52,11 +55,22 @@ public class RenameNodeCommand private String oldName; + /** + * Constructs a new RenameNodeCommand. + */ + public RenameNodeCommand() + { + newName = null; + oldName = null; + node = null; + diagram = null; + } + // setters public void setName(String name) { - this.newName = name; + newName = name; } public void setNode(Node node) @@ -72,35 +86,45 @@ public class RenameNodeCommand return "Rename Node"; } - public boolean canExecute(){ - return false; + public boolean canExecute() + { + return false; } + public void execute() - {/* if (newName.equals("")){ - Dialogs.displayErrorDialog("The name of the node can not be null!"); - return; - } - if (!NodeRegistrar.renameNode(oldName, newName, (Diagram)DiagramSingleton.getInstance().getDiagram())) + { + if (newName.equals("")) { - Dialogs.displayErrorDialog("The node, " + newName + ", already exists."); + displayErrorDialog("The name of the node can not be empty."); + return; + } + oldName = node.getName(); + String[] oldParts = oldName.split(":"); + String[] newParts = newName.split(":"); + String newComposedName = newParts[0] + ":" + oldParts[1]; + if (!NodeRegistrar.renameNode(oldName, newComposedName, + (Diagram)DiagramSingleton.getInstance().getDiagram())) + { + displayErrorDialog("The node, " + newComposedName + + ", already exists."); return; } - oldName = this.node.getName(); - this.node.setName(newName);*/ + node.setName(newComposedName); } public void undo() { - this.node.setName(oldName); + node.setName(oldName); } public void redo() { - this.node.setName(newName); + node.setName(newName); } + public void setDiagram(Diagram d) { - this.diagram = d; - DiagramSingleton.getInstance().setDiagram(d); + diagram = d; + DiagramSingleton.getInstance().setDiagram(d); } } Index: src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 ConnectionElement.java --- src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java 5 May 2005 23:47:58 -0000 1.1 +++ src/nongnu/cashews/eclipse/composer/model/ConnectionElement.java 19 May 2005 10:26:34 -0000 @@ -33,67 +33,91 @@ otherwise indicated below, the terms and conditions of the EPL still apply to any source code in the Content. - */ - +*/ package nongnu.cashews.eclipse.composer.model; import java.util.ArrayList; import nongnu.cashews.language.process.Connection; +import nongnu.cashews.language.process.Performance; -public class ConnectionElement extends Element +public class ConnectionElement + extends Element { /** - * Comment for serialVersionUID + * Serialization ID. */ private static final long serialVersionUID = 1L; + /** + * The target node. + * + * @serial the target node. + */ private Node target; + /** + * The source node. + * + * @serial the source node. + */ private Node source; - private Connection conn; + /** + * The model of the connection. + * + * @serial the connection model. + */ + private Connection connection; public ConnectionElement(Node source, Node target) { this.source = source; this.target = target; if (target.inputs != null) - { target.addInput(this); - } else { target.inputs = new ArrayList(); target.addInput(this); } if (source.outputs != null) - { source.addOutput(this); - } else { source.outputs = new ArrayList(); source.addOutput(this); } - conn = new Connection(); - PerformanceElement sourcePerformNode = (PerformanceElement) source; - conn.setFromPerformance(sourcePerformNode.getPerformance().getName()); - PerformanceElement targetPerformNode = (PerformanceElement) target; - conn.setToPerformance(targetPerformNode.getPerformance().getName()); - + connection = new Connection(); + Performance sourcePerform = + ((PerformanceElement) source).getPerformance(); + connection.setFromPerformance(sourcePerform.getName()); + Performance targetPerform = + ((PerformanceElement) target).getPerformance(); + connection.setToPerformance(targetPerform.getName()); } public Node getTarget() { - return this.target; + return target; } public Node getSource() { - return this.source; + return source; } + + /** + * Retrieves the underlying Connection model for this element. + * + * @return the connection model. + */ + public Connection getConnection() + { + return connection; + } + } Index: src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 ConnectionPart.java --- src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java 16 May 2005 14:22:13 -0000 1.3 +++ src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java 19 May 2005 10:26:34 -0000 @@ -37,10 +37,7 @@ to any source code in the Content. package nongnu.cashews.eclipse.composer.parts; -import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure; import nongnu.cashews.eclipse.composer.model.ConnectionElement; -import nongnu.cashews.eclipse.composer.model.PerformanceElement; -import nongnu.cashews.eclipse.composer.model.Node; import org.eclipse.draw2d.Ellipse; import org.eclipse.draw2d.FigureListener; @@ -48,14 +45,10 @@ import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.PolygonDecoration; import org.eclipse.draw2d.PolylineConnection; -import org.eclipse.draw2d.RoundedRectangle; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.editparts.AbstractConnectionEditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; public class ConnectionPart extends AbstractConnectionEditPart Index: src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 DiagramEditor.java --- src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java 16 May 2005 18:08:20 -0000 1.3 +++ src/nongnu/cashews/eclipse/composer/ui/DiagramEditor.java 19 May 2005 10:26:34 -0000 @@ -40,7 +40,6 @@ package nongnu.cashews.eclipse.composer. import java.io.InputStream; import java.util.EventObject; -import nongnu.cashews.eclipse.composer.dnd.DiagramTemplateTransferDropTargetListener; import nongnu.cashews.eclipse.composer.model.Diagram; import nongnu.cashews.eclipse.composer.model.ElementFactory; import nongnu.cashews.eclipse.composer.parts.PartFactory; Index: src/nongnu/cashews/eclipse/composer/wizards/ProcessData.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/composer/wizards/ProcessData.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 ProcessData.java --- src/nongnu/cashews/eclipse/composer/wizards/ProcessData.java 16 May 2005 14:22:13 -0000 1.2 +++ src/nongnu/cashews/eclipse/composer/wizards/ProcessData.java 19 May 2005 10:26:34 -0000 @@ -1,22 +1,73 @@ +/* ProcessData.java -- Data for the process wizard. + Copyright (C) 2005 The University of Sheffield. + +This file is part of the CASheW-s editor Eclipse plug-in. + +The CASheW-s editor Eclipse plug-in is free software; you may copy, modify, +and redistribute it under the terms of the GNU General Public License +version 2 (or, at your option, any later version), and/or the Eclipse +Public License version 1.0. + +The CASheW-s editor is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with The CASheW-s editor; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +The University of Sheffield makes available all content in this plug-in +("Content"). Unless otherwise indicated below, the Content is provided to +you under the terms and conditions of the Eclipse Public License Version +1.0 ("EPL"). A copy of the EPL is available at +http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, +"Program" will mean the Content. + +If you did not receive this Content directly from the University of Sheffield, +the Content is being redistributed by another party ("Redistributor") and +different terms and conditions may apply to your use of any object code in +the Content. Check the Redistributor's license that was provided with the +Content. If no such license exists, contact the Redistributor. Unless +otherwise indicated below, the terms and conditions of the EPL still apply +to any source code in the Content. + +*/ package nongnu.cashews.eclipse.composer.wizards; import java.util.HashSet; import java.util.List; import java.util.Set; -public class ProcessData { +/** + * Manages data for the process wizard. + * + * @author Xianfeng Liu (address@hidden) + * @author Andrew John Hughes (address@hidden) + */ +public class ProcessData +{ + + public String performanceName; + + public String operationName; + + public Set item = new HashSet(); + + public Object[] getElements(List inputElement) + { + return inputElement.toArray(); + } - public String performanceName; - public String operationName; - public Set item = new HashSet(); - public Object[] getElements(Object inputElement) { - return ((List) inputElement).toArray(); - } - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("Performance Name:\t" + performanceName.toString() + "\n"); - sb.append("Operation Name:\t" + operationName.toString() + "\n"); - return sb.toString(); + public String toString() + { + return getClass().getName() + + "[performanceName=" + + performanceName + + ", operationName=" + + operationName + + "]"; } Index: src/nongnu/cashews/eclipse/gui/Cashews.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/gui/Cashews.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 Cashews.java --- src/nongnu/cashews/eclipse/gui/Cashews.java 16 May 2005 18:08:20 -0000 1.3 +++ src/nongnu/cashews/eclipse/gui/Cashews.java 19 May 2005 10:26:34 -0000 @@ -23,10 +23,11 @@ package nongnu.cashews.eclipse.gui; import java.net.URI; -import nongnu.cashews.language.grounding.SoapOperation; import static nongnu.cashews.services.Processes.TEST_COMPOSITE_SEQUENCE; + import nongnu.cashews.services.WorkflowService; import nongnu.cashews.soap.SoapClient; +import nongnu.cashews.soap.SoapOperation; import org.eclipse.jface.window.ApplicationWindow; import org.eclipse.jface.wizard.WizardDialog; Index: src/nongnu/cashews/eclipse/gui/ConnectionPage.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/gui/ConnectionPage.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 ConnectionPage.java --- src/nongnu/cashews/eclipse/gui/ConnectionPage.java 13 May 2005 01:46:42 -0000 1.2 +++ src/nongnu/cashews/eclipse/gui/ConnectionPage.java 19 May 2005 10:26:34 -0000 @@ -21,41 +21,24 @@ package nongnu.cashews.eclipse.gui; -import java.io.File; -import java.io.IOException; - -import java.net.URISyntaxException; - import java.util.HashMap; import java.util.Map; -import java.util.logging.ConsoleHandler; import nongnu.cashews.language.process.AtomicProcess; import nongnu.cashews.language.process.MultiPerform; import nongnu.cashews.language.process.MultiPerformElement; import nongnu.cashews.language.process.Performance; -import nongnu.cashews.language.grounding.SoapOperation; -import nongnu.cashews.wsdl.WsdlParser; +import nongnu.cashews.soap.SoapOperation; -import org.eclipse.core.runtime.Status; - -import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.RowLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; -import org.xml.sax.SAXException; - /** * The wizard page for creating a connection. * @@ -101,7 +84,7 @@ public class ConnectionPage public Control getControl() { - CashewsWizard wizard = (CashewsWizard) getWizard(); + CashewsWizard wizard = (CashewsWizard) getWizard(); MultiPerform mp = (MultiPerform) wizard.getProcess().getControlStructure(); if (mp != null) { Index: src/nongnu/cashews/eclipse/gui/OperationChoicePage.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/eclipse/gui/OperationChoicePage.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 OperationChoicePage.java --- src/nongnu/cashews/eclipse/gui/OperationChoicePage.java 13 May 2005 01:46:42 -0000 1.2 +++ src/nongnu/cashews/eclipse/gui/OperationChoicePage.java 19 May 2005 10:26:34 -0000 @@ -36,7 +36,7 @@ import nongnu.cashews.language.process.A import nongnu.cashews.language.process.MultiPerform; import nongnu.cashews.language.process.Performance; -import nongnu.cashews.language.grounding.SoapOperation; +import nongnu.cashews.soap.SoapOperation; import nongnu.cashews.wsdl.WsdlParser; Index: src/nongnu/cashews/language/grounding/MessagePart.java =================================================================== RCS file: src/nongnu/cashews/language/grounding/MessagePart.java diff -N src/nongnu/cashews/language/grounding/MessagePart.java --- src/nongnu/cashews/language/grounding/MessagePart.java 9 May 2005 02:36:56 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,224 +0,0 @@ -/* MessagePart.java -- Part of a SOAP message body. - Copyright (C) 2005 The University of Sheffield. - - This file is part of the CASheW-s editor. - - The CASheW-s editor is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The CASheW-s editor is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with The CASheW-s editor; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. -*/ - -package nongnu.cashews.language.grounding; - -import java.net.URI; -import java.net.URISyntaxException; - -import javax.xml.namespace.QName; - -import nongnu.cashews.xml.Xmlizable; - -/** - * Represents a single part of a SOAP message body. This specifies - * the name and type of the element. - * - * @author Andrew John Hughes (address@hidden) - */ -public class MessagePart - implements Xmlizable -{ - - /** - * The URI which relates this part to the calculus. - * - * @serial the URI relating this part to the calculus. - */ - private URI uri; - - /** - * The name of the SOAP message part. - * - * @serial the message part name. - */ - private QName name; - - /** - * The type of the SOAP message part. - * - * @serial the message part's type. - */ - private QName type; - - /** - * Constructs a new message part with the specified URI. - * - * @param uri the uri of this message part. - * @throws URISyntaxException if the supplied name is not a valid URI. - */ - public MessagePart(String uri) - throws URISyntaxException - { - setURI(uri); - } - - /** - * Constructs a new message part with the specified URI. - * - * @param uri the uri of this message part. - */ - public MessagePart(URI uri) - { - setURI(uri); - } - - /** - * Sets the URI of this message part to that specified. - * - * @param uri the uri of this message part. - * @throws URISyntaxException if the supplied name is not a valid URI. - */ - public void setURI(String uri) - throws URISyntaxException - { - setURI(new URI(uri)); - } - - /** - * Sets the URI of this message part to that specified. - * - * @param uri the uri of this message part. - */ - public void setURI(URI uri) - { - this.uri = uri; - } - - /** - * Sets the qualified name of this SOAP message to that constructed - * from the supplied namespace URI and local part. - * - * @param namespaceURI the namespace URI of this SOAP message's name. - * @param localPart the local part of this SOAP message's name. - */ - public void setName(String namespaceURI, String localPart) - { - setName(new QName(namespaceURI, localPart)); - } - - /** - * Sets the qualified name of this SOAP message to that constructed - * from the supplied namespace URI, local part and prefix. - * - * @param namespaceURI the namespace URI of this SOAP message's name. - * @param localPart the local part of this SOAP message's name. - * @param prefix the prefix of this SOAP message's name. - */ - public void setName(String namespaceURI, String localPart, String prefix) - { - setName(new QName(namespaceURI, localPart, prefix)); - } - - /** - * Sets the name of this SOAP message to that specified. - * - * @param name the name of this SOAP message. - */ - public void setName(QName name) - { - this.name = name; - } - - /** - * Sets the type of this SOAP message to that constructed - * from the supplied namespace URI and local part. - * - * @param namespaceURI the namespace URI of this SOAP message's type. - * @param localPart the local part of this SOAP message's type. - */ - public void setType(String namespaceURI, String localPart) - { - setType(new QName(namespaceURI, localPart)); - } - - /** - * Sets the qualified type of this SOAP message to that constructed - * from the supplied namespace URI, local part and prefix. - * - * @param namespaceURI the namespace URI of this SOAP message's type. - * @param localPart the local part of this SOAP message's type. - * @param prefix the prefix of this SOAP message's type. - */ - public void setType(String namespaceURI, String localPart, String prefix) - { - setType(new QName(namespaceURI, localPart, prefix)); - } - - /** - * Sets the type of this SOAP message part to that specified. - * - * @param type the type of this SOAP message. - */ - public void setType(QName type) - { - this.type = type; - } - - /** - * Returns the name of this SOAP message part. - * - * @return the name of this SOAP message part. - */ - public QName getName() - { - return name; - } - - /** - * Returns a String representation of this SOAP message. - * - * @return a textual representation. - */ - public String toString() - { - return getClass().getName() + - "[uri=" + - uri + - ",name=" + - name + - ",type=" + - type + - "]"; - } - - /** - * Returns "part" as the element name for XML serialization. - * - * @return part - */ - public String getElementName() - { - return "part"; - } - - /** - * Returns null as this class needs no further namespace declarations. - * - * @return null. - */ - public QName[] getDeclaredNamespaces() - { - return null; - } - -} - Index: src/nongnu/cashews/language/grounding/SoapMessage.java =================================================================== RCS file: src/nongnu/cashews/language/grounding/SoapMessage.java diff -N src/nongnu/cashews/language/grounding/SoapMessage.java --- src/nongnu/cashews/language/grounding/SoapMessage.java 9 May 2005 02:36:56 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,187 +0,0 @@ -/* SoapMessage.java -- The message format for a SOAP envelope body. - Copyright (C) 2005 The University of Sheffield. - - This file is part of the CASheW-s editor. - - The CASheW-s editor is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The CASheW-s editor is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with The CASheW-s editor; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. -*/ - -package nongnu.cashews.language.grounding; - -import java.io.Serializable; - -import java.util.LinkedList; -import java.util.List; - -import javax.xml.namespace.QName; - -/** - * Specifies the format of the message body within a SOAP - * envelope. - * - * @author Andrew John Hughes (address@hidden) - */ -public class SoapMessage - implements Serializable -{ - - /** - * The name of the SOAP message. - * - * @serial the message name. - */ - private QName name; - - /** - * The separate parts which compose the message. - * - * @serial the message parts. - */ - private List parts; - - /** - * Constructs a new SOAP message. - */ - private SoapMessage() - { - parts = new LinkedList(); - } - - /** - * Constructs a new SOAP message with the specified qualified - * name, constructed from the supplied namespace URI and - * local part. - * - * @param namespaceURI the namespace URI of this SOAP message's name. - * @param localPart the local part of this SOAP message's name. - */ - public SoapMessage(String namespaceURI, String localPart) - { - this(); - setName(new QName(namespaceURI, localPart)); - } - - /** - * Constructs a new SOAP message with the specified qualified - * name, constructed from the supplied namespace URI, local part - * and prefix. - * - * @param namespaceURI the namespace URI of this SOAP message's name. - * @param localPart the local part of this SOAP message's name. - * @param prefix the prefix of this SOAP message's name. - */ - public SoapMessage(String namespaceURI, String localPart, String prefix) - { - this(); - setName(namespaceURI, localPart, prefix); - } - - /** - * Constructs a new SOAP message with the specified name. - * - * @param name the name of this SOAP message. - */ - public SoapMessage(QName name) - { - this(); - setName(name); - } - - /** - * Sets the qualified name of this SOAP message to that constructed - * from the supplied namespace URI and local part. - * - * @param namespaceURI the namespace URI of this SOAP message's name. - * @param localPart the local part of this SOAP message's name. - */ - public void setName(String namespaceURI, String localPart) - { - setName(new QName(namespaceURI, localPart)); - } - - /** - * Sets the qualified name of this SOAP message to that constructed - * from the supplied namespace URI, local part and prefix. - * - * @param namespaceURI the namespace URI of this SOAP message's name. - * @param localPart the local part of this SOAP message's name. - * @param prefix the prefix of this SOAP message's name. - */ - public void setName(String namespaceURI, String localPart, String prefix) - { - setName(new QName(namespaceURI, localPart, prefix)); - } - - /** - * Sets the name of this SOAP message to that specified. - * - * @param name the name of this SOAP message. - */ - public void setName(QName name) - { - this.name = name; - } - - /** - * Adds a new part to the SOAP message. - * - * @param part the new part to add. - */ - public boolean addPart(MessagePart part) - { - if (part == null) - return false; - parts.add(part); - return true; - } - - /** - * Retrieves the qualified name of this SOAP message. - * - * @return the qualified name of this SOAP message. - */ - public QName getName() - { - return name; - } - - /** - * Retrieves a shallow clone of the parts of this message. - * - * @return a shallow clone of the message parts. - */ - public List getParts() - { - return new LinkedList(parts); - } - - /** - * Returns a String representation of this SOAP message. - * - * @return a textual representation. - */ - public String toString() - { - return getClass().getName() + - "[name=" + - name + - ",parts=" + - parts + - "]"; - } - -} - Index: src/nongnu/cashews/language/grounding/SoapOperation.java =================================================================== RCS file: src/nongnu/cashews/language/grounding/SoapOperation.java diff -N src/nongnu/cashews/language/grounding/SoapOperation.java --- src/nongnu/cashews/language/grounding/SoapOperation.java 10 May 2005 23:42:47 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,254 +0,0 @@ -/* SoapOperation.java -- Representation of a SOAP operation. - Copyright (C) 2005 The University of Sheffield. - - This file is part of the CASheW-s editor. - - The CASheW-s editor is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The CASheW-s editor is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with The CASheW-s editor; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. -*/ - -package nongnu.cashews.language.grounding; - -import java.net.URI; -import java.net.URISyntaxException; - -import javax.xml.namespace.QName; - -import nongnu.cashews.xml.XmlField; -import nongnu.cashews.xml.Xmlizable; - -/** - * An implementation of Grounding for the Simple - * Object Access Protocol (SOAP). SOAP operations have an - * endpoint, a namespace, an input message and an output - * message, which specify the location, naming and data - * transmission of the operation respectively. - * - * @author Andrew John Hughes (address@hidden) - * @see Grounding - */ -public class SoapOperation - implements Grounding, Xmlizable -{ - - /** - * Serialization fields which specify how to serialize this class. - */ - private static final XmlField[] serialPersistentFields - = new XmlField[] - { - new XmlField("endpoint",URI.class), - new XmlField("namespace",URI.class), - new XmlField("inputMessage",SoapMessage.class,false,true,false), - new XmlField("outputMessage",SoapMessage.class,false,true,false) - }; - - /** - * The endpoint where the operation is located. - * - * @serial the endpoint of the operation. - */ - private URI endpoint; - - /** - * The namespace of this operation. - * - * @serial the operation namespace. - */ - private URI namespace; - - /** - * The message format for the input. - * - * @serial the input message format. - */ - private SoapMessage inputMessage; - - /** - * The message format for the output. - * - * @serial the output message format. - */ - private SoapMessage outputMessage; - - /** - * Constructs a new empty operation. - */ - public SoapOperation() - { - } - - /** - * Constructs a new operation using the specified endpoint. - * The endpoint is also used as the namespace of the operation. - * - * @param endpoint the endpoint of this SOAP operation. - * @throws URISyntaxException if the supplied endpoint is not a valid URI. - */ - public SoapOperation(String endpoint) - throws URISyntaxException - { - this(endpoint, endpoint); - } - - /** - * Constructs a new operation using the specified endpoint - * and namespace. - * - * @param endpoint the endpoint of this SOAP operation. - * @param namespace the namespace of this SOAP operation. - * @throws URISyntaxException if the supplied endpoint is not a valid URI. - */ - public SoapOperation(String endpoint, String namespace) - throws URISyntaxException - { - setEndpoint(endpoint); - setNamespace(namespace); - } - - /** - * Sets the endpoint of this SOAP operation to that specified. - * - * @param endpoint the endpoint of the operation. - * @throws URISyntaxException if the supplied endpoint is not a valid URI. - */ - public void setEndpoint(String endpoint) - throws URISyntaxException - { - setEndpoint(new URI(endpoint)); - } - - /** - * Sets the endpoint of this SOAP operation to that specified. - * - * @param endpoint the endpoint of the operation. - */ - public void setEndpoint(URI endpoint) - { - this.endpoint = endpoint; - } - - /** - * Sets the namespace of this SOAP operation to that specified. - * - * @param namespace the namespace of the operation. - * @throws URISyntaxException if the supplied namespace is not a valid URI. - */ - public void setNamespace(String namespace) - throws URISyntaxException - { - setNamespace(new URI(namespace)); - } - - /** - * Sets the namespace of this SOAP operation to that specified. - * - * @param namespace the namespace of the operation. - */ - public void setNamespace(URI namespace) - { - this.namespace = namespace; - } - - /** - * Sets the input message of this SOAP operation to that specified. - * - * @param inputMessage the input message of this operation. - */ - public void setInputMessage(SoapMessage inputMessage) - { - this.inputMessage = inputMessage; - } - - /** - * Sets the output message of this SOAP operation to that specified. - * - * @param outputMessage the output message of this operation. - */ - public void setOutputMessage(SoapMessage outputMessage) - { - this.outputMessage = outputMessage; - } - - /** - * Retrieves the endpoint of this operation. - * - * @return the operation endpoint. - */ - public URI getEndpoint() - { - return endpoint; - } - - /** - * Retrieves the input message of this operation. - * - * @return the operation's input message. - */ - public SoapMessage getInputMessage() - { - return inputMessage; - } - - /** - * Returns a String representation of this SOAP operation. - * - * @return a textual representation. - */ - public String toString() - { - return getClass().getName() + - "[endpoint=" + - endpoint + - ",namespace=" + - namespace + - ",inputMessage=" + - inputMessage + - ",outputMessage=" + - outputMessage + - "]"; - } - - /** - * Returns "soapOperation" as the element name. - * - * @return soapOperation - */ - public String getElementName() - { - return "soapOperation"; - } - - /** - * Retrieves an array of QNames which specifies the namespaces to - * declare when serializing this element as XML. - * - * @return an array of QNames for namespace declaration. - */ - public QName[] getDeclaredNamespaces() - { - if (inputMessage != null) - { - return new QName[] - { - inputMessage.getName() - }; - } - else - return null; - } - -} - Index: src/nongnu/cashews/language/process/AnyOrder.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/AnyOrder.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 AnyOrder.java --- src/nongnu/cashews/language/process/AnyOrder.java 4 May 2005 07:31:55 -0000 1.1 +++ src/nongnu/cashews/language/process/AnyOrder.java 19 May 2005 10:26:34 -0000 @@ -33,4 +33,9 @@ public class AnyOrder extends MultiPerform { + /** + * Serialization ID. + */ + private static final long serialVersionUID = -8802970059861733456L; + } Index: src/nongnu/cashews/language/process/AtomicProcess.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/AtomicProcess.java,v retrieving revision 1.5 diff -u -3 -p -u -r1.5 AtomicProcess.java --- src/nongnu/cashews/language/process/AtomicProcess.java 11 May 2005 07:16:05 -0000 1.5 +++ src/nongnu/cashews/language/process/AtomicProcess.java 19 May 2005 10:26:34 -0000 @@ -41,6 +41,11 @@ public class AtomicProcess { /** + * Serialization ID. + */ + private static final long serialVersionUID = 392344681325384303L; + + /** * Serialization fields which specify how to serialize this class. */ private static final XmlField[] serialPersistentFields Index: src/nongnu/cashews/language/process/ChooseOne.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/ChooseOne.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 ChooseOne.java --- src/nongnu/cashews/language/process/ChooseOne.java 4 May 2005 07:31:55 -0000 1.1 +++ src/nongnu/cashews/language/process/ChooseOne.java 19 May 2005 10:26:34 -0000 @@ -32,4 +32,9 @@ public class ChooseOne extends MultiPerform { + /** + * Serialization ID. + */ + private static final long serialVersionUID = -6583991590050684342L; + } Index: src/nongnu/cashews/language/process/CompositeProcess.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/CompositeProcess.java,v retrieving revision 1.5 diff -u -3 -p -u -r1.5 CompositeProcess.java --- src/nongnu/cashews/language/process/CompositeProcess.java 11 May 2005 07:16:05 -0000 1.5 +++ src/nongnu/cashews/language/process/CompositeProcess.java 19 May 2005 10:26:34 -0000 @@ -49,6 +49,11 @@ public class CompositeProcess { /** + * Serialization ID. + */ + private static final long serialVersionUID = -596999203319480770L; + + /** * The control structure which defines how this process operates. * * @serial the control structure. Index: src/nongnu/cashews/language/process/Connection.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/Connection.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 Connection.java --- src/nongnu/cashews/language/process/Connection.java 5 May 2005 23:47:59 -0000 1.2 +++ src/nongnu/cashews/language/process/Connection.java 19 May 2005 10:26:34 -0000 @@ -24,6 +24,10 @@ package nongnu.cashews.language.process; import java.net.URI; import java.net.URISyntaxException; +import javax.xml.namespace.QName; + +import nongnu.cashews.xml.Xmlizable; + /** * Represents the connection between two performances, which provides * the necessary data flow from one to the other. The output of @@ -32,10 +36,15 @@ import java.net.URISyntaxException; * @author Andrew John Hughes (address@hidden) */ public class Connection - implements MultiPerformElement + implements MultiPerformElement, Xmlizable { /** + * Serialization ID. + */ + private static final long serialVersionUID = -664689479913445752L; + + /** * The performance from which the output comes. * * @serial the source performance. @@ -114,4 +123,24 @@ public class Connection toPerformance = name; } + /** + * Returns "connect" as the element name for XML serialization. + * + * @return connect + */ + public String getElementName() + { + return "connect"; + } + + /** + * Returns null as this class needs no further namespace declarations. + * + * @return null. + */ + public QName[] getDeclaredNamespaces() + { + return null; + } + } Index: src/nongnu/cashews/language/process/Consume.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/Consume.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 Consume.java --- src/nongnu/cashews/language/process/Consume.java 7 May 2005 21:22:54 -0000 1.2 +++ src/nongnu/cashews/language/process/Consume.java 19 May 2005 10:26:34 -0000 @@ -39,6 +39,11 @@ public class Consume { /** + * Serialization ID. + */ + private static final long serialVersionUID = 8930934887277907561L; + + /** * The input on the composite process. * * @serial the source input. Index: src/nongnu/cashews/language/process/IfThenElse.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/IfThenElse.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 IfThenElse.java --- src/nongnu/cashews/language/process/IfThenElse.java 4 May 2005 22:14:05 -0000 1.2 +++ src/nongnu/cashews/language/process/IfThenElse.java 19 May 2005 10:26:34 -0000 @@ -36,6 +36,11 @@ public class IfThenElse { /** + * Serialization ID. + */ + private static final long serialVersionUID = -4509789183463049503L; + + /** * The condition on which the branch is decided. * * @serial the condition. Index: src/nongnu/cashews/language/process/Loop.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/Loop.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 Loop.java --- src/nongnu/cashews/language/process/Loop.java 4 May 2005 22:14:05 -0000 1.2 +++ src/nongnu/cashews/language/process/Loop.java 19 May 2005 10:26:34 -0000 @@ -35,6 +35,11 @@ public class Loop { /** + * Serialization ID. + */ + private static final long serialVersionUID = 1765198692835716329L; + + /** * The condition on which the loop depends. * * @serial the condition. Index: src/nongnu/cashews/language/process/Performance.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/Performance.java,v retrieving revision 1.4 diff -u -3 -p -u -r1.4 Performance.java --- src/nongnu/cashews/language/process/Performance.java 7 May 2005 21:22:54 -0000 1.4 +++ src/nongnu/cashews/language/process/Performance.java 19 May 2005 10:26:34 -0000 @@ -48,6 +48,11 @@ public class Performance { /** + * Serialization ID. + */ + private static final long serialVersionUID = 4837492112554636887L; + + /** * The name of this performance. * * @serial the performance name. Index: src/nongnu/cashews/language/process/Produce.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/Produce.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 Produce.java --- src/nongnu/cashews/language/process/Produce.java 7 May 2005 21:22:54 -0000 1.2 +++ src/nongnu/cashews/language/process/Produce.java 19 May 2005 10:26:34 -0000 @@ -39,6 +39,11 @@ public class Produce { /** + * Serialization ID. + */ + private static final long serialVersionUID = 5294647615023191593L; + + /** * The output of the composite process. * * @serial the composite process output. Index: src/nongnu/cashews/language/process/RepeatUntil.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/RepeatUntil.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 RepeatUntil.java --- src/nongnu/cashews/language/process/RepeatUntil.java 4 May 2005 07:31:55 -0000 1.1 +++ src/nongnu/cashews/language/process/RepeatUntil.java 19 May 2005 10:26:34 -0000 @@ -30,4 +30,10 @@ package nongnu.cashews.language.process; public class RepeatUntil extends Loop { + + /** + * Serialization ID. + */ + private static final long serialVersionUID = -4224625111021445742L; + } Index: src/nongnu/cashews/language/process/RepeatWhile.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/RepeatWhile.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 RepeatWhile.java --- src/nongnu/cashews/language/process/RepeatWhile.java 4 May 2005 07:31:55 -0000 1.1 +++ src/nongnu/cashews/language/process/RepeatWhile.java 19 May 2005 10:26:34 -0000 @@ -30,4 +30,10 @@ package nongnu.cashews.language.process; public class RepeatWhile extends Loop { + + /** + * Serialization ID. + */ + private static final long serialVersionUID = 8675937682333353419L; + } Index: src/nongnu/cashews/language/process/Sequence.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/Sequence.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 Sequence.java --- src/nongnu/cashews/language/process/Sequence.java 4 May 2005 07:31:55 -0000 1.1 +++ src/nongnu/cashews/language/process/Sequence.java 19 May 2005 10:26:34 -0000 @@ -32,5 +32,10 @@ package nongnu.cashews.language.process; public class Sequence extends MultiPerform { + + /** + * Serialization ID. + */ + private static final long serialVersionUID = -7367485578578570740L; } Index: src/nongnu/cashews/language/process/Split.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/Split.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 Split.java --- src/nongnu/cashews/language/process/Split.java 4 May 2005 07:31:55 -0000 1.1 +++ src/nongnu/cashews/language/process/Split.java 19 May 2005 10:26:34 -0000 @@ -33,4 +33,9 @@ public class Split extends MultiPerform { + /** + * Serialization ID. + */ + private static final long serialVersionUID = 4617295223752680342L; + } Index: src/nongnu/cashews/language/process/SplitJoin.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/language/process/SplitJoin.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 SplitJoin.java --- src/nongnu/cashews/language/process/SplitJoin.java 4 May 2005 07:31:55 -0000 1.1 +++ src/nongnu/cashews/language/process/SplitJoin.java 19 May 2005 10:26:34 -0000 @@ -32,4 +32,10 @@ package nongnu.cashews.language.process; public class SplitJoin extends MultiPerform { + + /** + * Serialization ID. + */ + private static final long serialVersionUID = 5297671167482953984L; + } Index: src/nongnu/cashews/rdf/Blank.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/rdf/Blank.java,v retrieving revision 1.2 diff -u -3 -p -u -r1.2 Blank.java --- src/nongnu/cashews/rdf/Blank.java 17 Apr 2005 18:35:32 -0000 1.2 +++ src/nongnu/cashews/rdf/Blank.java 19 May 2005 10:26:34 -0000 @@ -21,6 +21,11 @@ package nongnu.cashews.rdf; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + /** *

* Blank nodes allow different parts of an RDF graph to be connected, @@ -28,6 +33,12 @@ package nongnu.cashews.rdf; * node has an identifier, which allows it to be used and referenced * in a triple. *

+ *

+ * Note: Blank nodes are not created via a constructor. + * They are created via the methods generateBlankNode() and + * generateBlankNode(String) in order to ensure identifier + * uniqueness. + *

* * @author Andrew John Hughes (address@hidden) */ @@ -36,6 +47,19 @@ public class Blank { /** + * The map of graphs to blank node IDs. + */ + private static Map> nodeIds; + + /** + * Static initializer for the blank node set. + */ + static + { + nodeIds = new HashMap>(); + } + + /** * The identifier for this blank node. * * @serial the identifier for this node. @@ -43,13 +67,47 @@ public class Blank private String id; /** - * Constructs a Blank using the specified identifier. + * Private constructor to prevent manual creation. + */ + private Blank() + { + } + + /** + * Constructs a Blank node for the specified graph + * using an automatically generated identifier. + * + * @param graph the graph of which the blank node will be a part. + * @return a Blank node. + */ + public static Blank generateBlankNode(Graph graph) + { + boolean added = false; + Blank blank = new Blank(); + String randomId; + do + { + randomId = Long.toString(Math.round(Math.random() * Long.MAX_VALUE)); + added = blank.setIdentifier(graph, randomId); + } while (!added); + return blank; + } + + /** + * Constructs a Blank node for the specified graph + * using the supplied identifier. * + * @param graph the graph of which the blank node will be a part. * @param identifier the identifier for this blank node. + * @return a Blank node or null if a + * unique identifier could not be generated. */ - public Blank(String identifier) + public static Blank generateBlankNode(Graph graph, String identifier) { - setIdentifier(identifier); + Blank blank = new Blank(); + if (blank.setIdentifier(graph, identifier)) + return blank; + return null; } /** @@ -77,13 +135,65 @@ public class Blank } /** - * Sets the identifier used by the blank node to the one specified. + * Sets the identifier used by the blank node to be the one specified, + * provided the identifier is unique to the graph supplied. * + * @param graph the graph of which the blank node will be a part. * @param identifier the new identifier to use. + * @return true if the identifier was changed. + */ + public boolean setIdentifier(Graph graph, String identifier) + { + Set idSet = nodeIds.get(graph); + if (idSet == null) + { + idSet = new HashSet(); + nodeIds.put(graph, idSet); + } + if (idSet.add(identifier)) + { + id = identifier; + return true; + } + return false; + } + + /** + * Returns the identifier of this blank node. + * + * @return the blank node identifier. + */ + public String getIdentifier() + { + /* Strings are immutable, so we just return it. */ + return id; + } + + /** + * Returns true if the specified object is a blank node and + * is equal to this one. + * + * @param object the object to compare. + */ + public boolean equals(Object obj) + { + if (super.equals(obj)) + { + Blank blank = (Blank) obj; + return id.equals(blank.getIdentifier()); + } + return false; + } + + /** + * Returns the hashcode of this blank node. This is calculated using + * the identifier's hash code and that of the super class. + * + * @return the hashcode for the blank node. */ - public void setIdentifier(String identifier) + public int hashCode() { - id = identifier; + return super.hashCode() + 17 * id.hashCode(); } } Index: src/nongnu/cashews/rdf/Literal.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/rdf/Literal.java,v retrieving revision 1.5 diff -u -3 -p -u -r1.5 Literal.java --- src/nongnu/cashews/rdf/Literal.java 5 Apr 2005 16:48:53 -0000 1.5 +++ src/nongnu/cashews/rdf/Literal.java 19 May 2005 10:26:34 -0000 @@ -65,7 +65,20 @@ public class Literal */ public Literal(String lexicalForm) { - this.lexicalForm = lexicalForm; + setLexicalForm(lexicalForm); + } + + /** + * Constructs a Literal using the specified lexical form + * and language. + * + * @param lexicalForm the lexical form of this literal. + * @param language the language of this literal. + */ + public Literal(String lexicalForm, String language) + { + this(lexicalForm); + setLanguage(language); } /** @@ -128,4 +141,96 @@ public class Literal this.type = type; } + /** + * Returns the literal's type. + * + * @return the type of the literal. + */ + public Type getType() + { + return type; + } + + /** + * Sets the lexical form used by the literal to the one specified. + * + * @param lexicalForm the new lexical form of the literal. + * @return true if the lexical form was changed, false + * if the supplied value was null. + */ + public boolean setLexicalForm(String lexicalForm) + { + if (lexicalForm == null) + return false; + this.lexicalForm = lexicalForm; + return true; + } + + /** + * Returns the literal's lexical form. + * + * @return the lexical form of the literal. + */ + public String getLexicalForm() + { + /* Strings are immutable, so no clone required. */ + return lexicalForm; + } + + /** + * Sets the language used by the literal to the one specified. + * + * @param language the language of the literal. + */ + public void setLanguage(String language) + { + this.language = language; + } + + /** + * Returns the literal's language. + * + * @return the language of the literal. + */ + public String getLanguage() + { + /* Strings are immutable, so no clone required. */ + return language; + } + + /** + * Returns true if the specified object is a literal and + * is equal to this one. + * + * @param object the object to compare. + */ + public boolean equals(Object obj) + { + if (obj == null) + return false; + if (obj == this) + return true; + if (obj.getClass() == getClass()) + { + Literal literal = (Literal) obj; + return (lexicalForm.equals(literal.getLexicalForm()) + && (language.equals(literal.getLanguage())) + && (type.equals(literal.getType()))); + } + return false; + } + + /** + * Returns the hashcode of this literal. This is calculated using + * the hashcodes of the lexical form, language and type. + * + * @return the hashcode for the blank node. + */ + public int hashCode() + { + return 13 * lexicalForm.hashCode() + + (language == null ? 0 : 17 * language.hashCode()) + + (type == null ? 0 : 19 * type.hashCode()); + } + } Index: src/nongnu/cashews/rdf/Node.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/rdf/Node.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 Node.java --- src/nongnu/cashews/rdf/Node.java 17 Apr 2005 18:35:32 -0000 1.3 +++ src/nongnu/cashews/rdf/Node.java 19 May 2005 10:26:34 -0000 @@ -62,6 +62,7 @@ public abstract class Node throw new IllegalStateException("Unexpected exception: " + e, e); } } + /** * Sets the type of this node to that supplied. * @@ -73,20 +74,14 @@ public abstract class Node } /** - * Retrieves a clone of the current type of this node. + * Retrieves the current type of this node. * - * @return a clone of the current type. + * @return the current type. */ public URI getType() { - try - { - return (type == null ? null : new URI(type.toString())); - } - catch (URISyntaxException e) - { - throw new IllegalStateException("The URI is invalid.", e); - } + /* URIs are immutable, so we don't need to clone */ + return type; } /** @@ -107,6 +102,8 @@ public abstract class Node * String. * * @param type the new type of the subject, in String form. + * @throws IllegalArgumentException if the supplied argument was not a + * valid URI. */ public void setType(String type) { @@ -120,5 +117,35 @@ public abstract class Node } } + /** + * Returns true if the specified object is a node and + * is equal to this one. + * + * @param object the object to compare. + */ + public boolean equals(Object obj) + { + if (obj == null) + return false; + if (obj == this) + return true; + if (obj.getClass() == getClass()) + { + Node node = (Node) obj; + return type.equals(node.getType()); + } + return false; + } + + /** + * Returns the hashcode of this node. This is calculated using + * the type's hash code. + * + * @return the hashcode for the node. + */ + public int hashCode() + { + return (type == null ? 0 : 13 * type.hashCode()); + } } Index: src/nongnu/cashews/rdf/RDFHandler.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/rdf/RDFHandler.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 RDFHandler.java --- src/nongnu/cashews/rdf/RDFHandler.java 4 May 2005 07:31:55 -0000 1.3 +++ src/nongnu/cashews/rdf/RDFHandler.java 19 May 2005 10:26:35 -0000 @@ -23,9 +23,7 @@ package nongnu.cashews.rdf; import java.net.URI; import java.net.URISyntaxException; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.logging.Handler; import java.util.logging.Logger; @@ -142,11 +140,6 @@ public class RDFHandler private PairStack currentState; /** - * The set of blank node IDs. - */ - private Set nodeIDs; - - /** * Constructs a new RDFHandler, using the specified * handler for log messages. * @@ -179,7 +172,6 @@ public class RDFHandler graph = new Graph(); subjectURI = null; currentState = new PairStack(); - nodeIDs = new HashSet(); } /** @@ -247,8 +239,15 @@ public class RDFHandler value = attributes.getValue(RDF_NAMESPACE, "nodeID"); if (value != null) { - object = new Blank(value); - rdfLogger.fine("Created object: " + object); + Blank blank = Blank.generateBlankNode(graph,value); + if (blank != null) + { + object = blank; + rdfLogger.fine("Created object: " + object); + } + else + rdfLogger.severe("Duplicate blank node ID: " + + value); } } /* Check for a type */ @@ -281,7 +280,7 @@ public class RDFHandler { try { - return new RDFURI(new URI(value)); + return new RDFURI(value); } catch (URISyntaxException e) { @@ -432,14 +431,14 @@ public class RDFHandler if (value != null) { attributes.remove(RDF_NAMESPACE, "nodeID"); - boolean added = nodeIDs.add(value); - if (added) - subject = new Blank(value); + Blank blank = Blank.generateBlankNode(graph,value); + if (blank != null) + subject = blank; else rdfLogger.severe("Duplicate blank node ID: " + value); } else - subject = new Blank(generateBlankID()); + subject = Blank.generateBlankNode(graph); } } if (subject == null) @@ -479,23 +478,6 @@ public class RDFHandler } /** - * Generate an ID for a blank node. - * - * @return a blank node ID. - */ - private String generateBlankID() - { - boolean added = false; - String randomID; - do - { - randomID = Long.toString(Math.round(Math.random() * Long.MAX_VALUE)); - added = nodeIDs.add(randomID); - } while (!added); - return randomID; - } - - /** * Handle the end of a subject node, including one that is * nested inside another. Subject nodes take two forms, so * it becomes necessary to have common handling for these. Index: src/nongnu/cashews/rdf/RDFURI.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/rdf/RDFURI.java,v retrieving revision 1.6 diff -u -3 -p -u -r1.6 RDFURI.java --- src/nongnu/cashews/rdf/RDFURI.java 17 Apr 2005 18:35:32 -0000 1.6 +++ src/nongnu/cashews/rdf/RDFURI.java 19 May 2005 10:26:35 -0000 @@ -49,6 +49,19 @@ public class RDFURI * Constructs an RDFURI using the specified URI. * * @param uri the URI to use for this RDF URI. + * @throws URISyntaxException if the supplied String + * does not form a valid URI. + */ + public RDFURI(String uri) + throws URISyntaxException + { + this(new URI(uri)); + } + + /** + * Constructs an RDFURI using the specified URI. + * + * @param uri the URI to use for this RDF URI. */ public RDFURI(URI uri) { @@ -70,20 +83,14 @@ public class RDFURI } /** - * Returns a clone of the URI used by this RDF URI. + * Returns he URI used by this RDF URI. * - * @return a clone of the URI. + * @return the URI. */ public URI getURI() { - try - { - return new URI(uri.toString()); - } - catch (URISyntaxException e) - { - throw new IllegalStateException("The URI is invalid.", e); - } + /* URIs are immutable, so we don't need to clone */ + return uri; } /** @@ -93,10 +100,17 @@ public class RDFURI */ public RDFURI clone() { - Object clonedObject = super.clone(); - RDFURI clone = (RDFURI) clonedObject; - clone.setURI(getURI()); - return clone; + try + { + Object clonedObject = super.clone(); + RDFURI clone = (RDFURI) clonedObject; + clone.setURI(new URI(uri.toString())); + return clone; + } + catch (URISyntaxException e) + { + throw new IllegalStateException("Invalid URI detected in cloning.",e); + } } /** @@ -109,4 +123,31 @@ public class RDFURI this.uri = uri; } + /** + * Returns true if the specified object is a RDF URI and + * is equal to this one. + * + * @param object the object to compare. + */ + public boolean equals(Object obj) + { + if (super.equals(obj)) + { + RDFURI rdfUri = (RDFURI) obj; + return uri.equals(rdfUri.getURI()); + } + return false; + } + + /** + * Returns the hashcode of this RDF URI. This is calculated using + * the uri's hash code and that of the superclass. + * + * @return the hashcode for this RDF URI. + */ + public int hashCode() + { + return super.hashCode() + 17 * uri.hashCode(); + } + } Index: src/nongnu/cashews/rdf/Triple.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/rdf/Triple.java,v retrieving revision 1.4 diff -u -3 -p -u -r1.4 Triple.java --- src/nongnu/cashews/rdf/Triple.java 4 Apr 2005 00:59:33 -0000 1.4 +++ src/nongnu/cashews/rdf/Triple.java 19 May 2005 10:26:35 -0000 @@ -190,10 +190,10 @@ public class Triple */ public int hashCode() { - return super.hashCode() - + 13 * subject.hashCode() - + 17 * predicate.hashCode() - + 19 * object.hashCode(); + return + 13 * subject.hashCode() + + 17 * predicate.hashCode() + + 19 * object.hashCode(); } /** Index: src/nongnu/cashews/services/KeyValueService.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/services/KeyValueService.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 KeyValueService.java --- src/nongnu/cashews/services/KeyValueService.java 13 May 2005 01:46:43 -0000 1.1 +++ src/nongnu/cashews/services/KeyValueService.java 19 May 2005 10:26:35 -0000 @@ -24,7 +24,6 @@ package nongnu.cashews.services; import java.io.IOException; import java.net.MalformedURLException; -import java.net.URI; import java.net.URISyntaxException; import java.util.LinkedList; @@ -32,11 +31,10 @@ import java.util.List; import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import nongnu.cashews.language.grounding.MessagePart; -import nongnu.cashews.language.grounding.SoapMessage; -import nongnu.cashews.language.grounding.SoapOperation; - +import nongnu.cashews.soap.MessagePart; import nongnu.cashews.soap.SoapClient; +import nongnu.cashews.soap.SoapMessage; +import nongnu.cashews.soap.SoapOperation; /** * Represents the CASheW-s key-value service. Index: src/nongnu/cashews/services/Processes.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/services/Processes.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 Processes.java --- src/nongnu/cashews/services/Processes.java 9 May 2005 02:36:56 -0000 1.1 +++ src/nongnu/cashews/services/Processes.java 19 May 2005 10:26:35 -0000 @@ -25,10 +25,6 @@ import java.net.URISyntaxException; import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import nongnu.cashews.language.grounding.MessagePart; -import nongnu.cashews.language.grounding.SoapMessage; -import nongnu.cashews.language.grounding.SoapOperation; - import nongnu.cashews.language.process.AtomicProcess; import nongnu.cashews.language.process.CompositeProcess; import nongnu.cashews.language.process.Consume; @@ -36,6 +32,10 @@ import nongnu.cashews.language.process.P import nongnu.cashews.language.process.Produce; import nongnu.cashews.language.process.Sequence; +import nongnu.cashews.soap.MessagePart; +import nongnu.cashews.soap.SoapMessage; +import nongnu.cashews.soap.SoapOperation; + /** * Test CASheW-s processes for use in service calls. * Index: src/nongnu/cashews/services/TypeChecker.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/services/TypeChecker.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 TypeChecker.java --- src/nongnu/cashews/services/TypeChecker.java 13 May 2005 01:46:43 -0000 1.3 +++ src/nongnu/cashews/services/TypeChecker.java 19 May 2005 10:26:35 -0000 @@ -30,11 +30,10 @@ import java.net.URISyntaxException; import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import nongnu.cashews.language.grounding.MessagePart; -import nongnu.cashews.language.grounding.SoapMessage; -import nongnu.cashews.language.grounding.SoapOperation; - +import nongnu.cashews.soap.MessagePart; import nongnu.cashews.soap.SoapClient; +import nongnu.cashews.soap.SoapMessage; +import nongnu.cashews.soap.SoapOperation; /** * A client implementation to call the type checking web service. Index: src/nongnu/cashews/services/WorkflowService.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/services/WorkflowService.java,v retrieving revision 1.1 diff -u -3 -p -u -r1.1 WorkflowService.java --- src/nongnu/cashews/services/WorkflowService.java 13 May 2005 01:46:43 -0000 1.1 +++ src/nongnu/cashews/services/WorkflowService.java 19 May 2005 10:26:35 -0000 @@ -29,13 +29,12 @@ import java.net.URISyntaxException; import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI; -import nongnu.cashews.language.grounding.MessagePart; -import nongnu.cashews.language.grounding.SoapMessage; -import nongnu.cashews.language.grounding.SoapOperation; - import static nongnu.cashews.services.Processes.TEST_COMPOSITE_SEQUENCE; +import nongnu.cashews.soap.MessagePart; import nongnu.cashews.soap.SoapClient; +import nongnu.cashews.soap.SoapMessage; +import nongnu.cashews.soap.SoapOperation; /** * Represents the CASheW-s workflow service. Index: src/nongnu/cashews/soap/MessagePart.java =================================================================== RCS file: src/nongnu/cashews/soap/MessagePart.java diff -N src/nongnu/cashews/soap/MessagePart.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/soap/MessagePart.java 19 May 2005 10:26:35 -0000 @@ -0,0 +1,229 @@ +/* MessagePart.java -- Part of a SOAP message body. + Copyright (C) 2005 The University of Sheffield. + + This file is part of the CASheW-s editor. + + The CASheW-s editor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. +*/ + +package nongnu.cashews.soap; + +import java.net.URI; +import java.net.URISyntaxException; + +import javax.xml.namespace.QName; + +import nongnu.cashews.xml.Xmlizable; + +/** + * Represents a single part of a SOAP message body. This specifies + * the name and type of the element. + * + * @author Andrew John Hughes (address@hidden) + */ +public class MessagePart + implements Xmlizable +{ + + /** + * Serialization ID. + */ + private static final long serialVersionUID = 6949869168445119169L; + + /** + * The URI which relates this part to the calculus. + * + * @serial the URI relating this part to the calculus. + */ + private URI uri; + + /** + * The name of the SOAP message part. + * + * @serial the message part name. + */ + private QName name; + + /** + * The type of the SOAP message part. + * + * @serial the message part's type. + */ + private QName type; + + /** + * Constructs a new message part with the specified URI. + * + * @param uri the uri of this message part. + * @throws URISyntaxException if the supplied name is not a valid URI. + */ + public MessagePart(String uri) + throws URISyntaxException + { + setURI(uri); + } + + /** + * Constructs a new message part with the specified URI. + * + * @param uri the uri of this message part. + */ + public MessagePart(URI uri) + { + setURI(uri); + } + + /** + * Sets the URI of this message part to that specified. + * + * @param uri the uri of this message part. + * @throws URISyntaxException if the supplied name is not a valid URI. + */ + public void setURI(String uri) + throws URISyntaxException + { + setURI(new URI(uri)); + } + + /** + * Sets the URI of this message part to that specified. + * + * @param uri the uri of this message part. + */ + public void setURI(URI uri) + { + this.uri = uri; + } + + /** + * Sets the qualified name of this SOAP message to that constructed + * from the supplied namespace URI and local part. + * + * @param namespaceURI the namespace URI of this SOAP message's name. + * @param localPart the local part of this SOAP message's name. + */ + public void setName(String namespaceURI, String localPart) + { + setName(new QName(namespaceURI, localPart)); + } + + /** + * Sets the qualified name of this SOAP message to that constructed + * from the supplied namespace URI, local part and prefix. + * + * @param namespaceURI the namespace URI of this SOAP message's name. + * @param localPart the local part of this SOAP message's name. + * @param prefix the prefix of this SOAP message's name. + */ + public void setName(String namespaceURI, String localPart, String prefix) + { + setName(new QName(namespaceURI, localPart, prefix)); + } + + /** + * Sets the name of this SOAP message to that specified. + * + * @param name the name of this SOAP message. + */ + public void setName(QName name) + { + this.name = name; + } + + /** + * Sets the type of this SOAP message to that constructed + * from the supplied namespace URI and local part. + * + * @param namespaceURI the namespace URI of this SOAP message's type. + * @param localPart the local part of this SOAP message's type. + */ + public void setType(String namespaceURI, String localPart) + { + setType(new QName(namespaceURI, localPart)); + } + + /** + * Sets the qualified type of this SOAP message to that constructed + * from the supplied namespace URI, local part and prefix. + * + * @param namespaceURI the namespace URI of this SOAP message's type. + * @param localPart the local part of this SOAP message's type. + * @param prefix the prefix of this SOAP message's type. + */ + public void setType(String namespaceURI, String localPart, String prefix) + { + setType(new QName(namespaceURI, localPart, prefix)); + } + + /** + * Sets the type of this SOAP message part to that specified. + * + * @param type the type of this SOAP message. + */ + public void setType(QName type) + { + this.type = type; + } + + /** + * Returns the name of this SOAP message part. + * + * @return the name of this SOAP message part. + */ + public QName getName() + { + return name; + } + + /** + * Returns a String representation of this SOAP message. + * + * @return a textual representation. + */ + public String toString() + { + return getClass().getName() + + "[uri=" + + uri + + ",name=" + + name + + ",type=" + + type + + "]"; + } + + /** + * Returns "part" as the element name for XML serialization. + * + * @return part + */ + public String getElementName() + { + return "part"; + } + + /** + * Returns null as this class needs no further namespace declarations. + * + * @return null. + */ + public QName[] getDeclaredNamespaces() + { + return null; + } + +} + Index: src/nongnu/cashews/soap/SoapClient.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/soap/SoapClient.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 SoapClient.java --- src/nongnu/cashews/soap/SoapClient.java 13 May 2005 01:46:43 -0000 1.3 +++ src/nongnu/cashews/soap/SoapClient.java 19 May 2005 10:26:35 -0000 @@ -34,10 +34,6 @@ import java.util.List; import static nongnu.cashews.commons.Configuration.CASHEWS_VERSION; -import nongnu.cashews.language.grounding.MessagePart; -import nongnu.cashews.language.grounding.SoapMessage; -import nongnu.cashews.language.grounding.SoapOperation; - import nongnu.cashews.xml.Serializer; import nongnu.cashews.xml.schema.TypeMapper; @@ -70,6 +66,8 @@ public class SoapClient InstantiationException, IllegalAccessException, ClassNotFoundException { + InputStream istream = null; + OutputStream ostream = null; Document document = serializeOperation(operation, args); HttpURLConnection connection = (HttpURLConnection) operation.getEndpoint().toURL().openConnection(); @@ -80,27 +78,38 @@ public class SoapClient "CASheW-s " + CASHEWS_VERSION); connection.setRequestMethod("POST"); connection.setDoOutput(true); - OutputStream ostream = connection.getOutputStream(); - Serializer.serializeToStream(document, ostream); - connection.connect(); - /* - System.out.println(connection.getContent()); - */ - InputStream istream = connection.getInputStream(); - BufferedReader reader = new BufferedReader(new InputStreamReader(istream)); - String line = reader.readLine(); - while (line != null) + try + { + ostream = connection.getOutputStream(); + Serializer.serializeToStream(document, ostream); + connection.connect(); + /* + System.out.println(connection.getContent()); + */ + istream = connection.getInputStream(); + BufferedReader reader = + new BufferedReader(new InputStreamReader(istream)); + String line = reader.readLine(); + while (line != null) + { + System.out.println(line); + line = reader.readLine(); + } + /* + return null; + */ + if (connection.getResponseCode() == 200) + return Boolean.valueOf(true); + else + return Boolean.valueOf(false); + } + finally { - System.out.println(line); - line = reader.readLine(); + if (istream != null) + istream.close(); + if (ostream != null) + ostream.close(); } - /* - return null; - */ - if (connection.getResponseCode() == 200) - return new Boolean(true); - else - return new Boolean(false); } /** Index: src/nongnu/cashews/soap/SoapMessage.java =================================================================== RCS file: src/nongnu/cashews/soap/SoapMessage.java diff -N src/nongnu/cashews/soap/SoapMessage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/soap/SoapMessage.java 19 May 2005 10:26:35 -0000 @@ -0,0 +1,192 @@ +/* SoapMessage.java -- The message format for a SOAP envelope body. + Copyright (C) 2005 The University of Sheffield. + + This file is part of the CASheW-s editor. + + The CASheW-s editor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. +*/ + +package nongnu.cashews.soap; + +import java.io.Serializable; + +import java.util.LinkedList; +import java.util.List; + +import javax.xml.namespace.QName; + +/** + * Specifies the format of the message body within a SOAP + * envelope. + * + * @author Andrew John Hughes (address@hidden) + */ +public class SoapMessage + implements Serializable +{ + + /** + * Serialization ID. + */ + private static final long serialVersionUID = -1769902414651528057L; + + /** + * The name of the SOAP message. + * + * @serial the message name. + */ + private QName name; + + /** + * The separate parts which compose the message. + * + * @serial the message parts. + */ + private List parts; + + /** + * Constructs a new SOAP message. + */ + private SoapMessage() + { + parts = new LinkedList(); + } + + /** + * Constructs a new SOAP message with the specified qualified + * name, constructed from the supplied namespace URI and + * local part. + * + * @param namespaceURI the namespace URI of this SOAP message's name. + * @param localPart the local part of this SOAP message's name. + */ + public SoapMessage(String namespaceURI, String localPart) + { + this(); + setName(new QName(namespaceURI, localPart)); + } + + /** + * Constructs a new SOAP message with the specified qualified + * name, constructed from the supplied namespace URI, local part + * and prefix. + * + * @param namespaceURI the namespace URI of this SOAP message's name. + * @param localPart the local part of this SOAP message's name. + * @param prefix the prefix of this SOAP message's name. + */ + public SoapMessage(String namespaceURI, String localPart, String prefix) + { + this(); + setName(namespaceURI, localPart, prefix); + } + + /** + * Constructs a new SOAP message with the specified name. + * + * @param name the name of this SOAP message. + */ + public SoapMessage(QName name) + { + this(); + setName(name); + } + + /** + * Sets the qualified name of this SOAP message to that constructed + * from the supplied namespace URI and local part. + * + * @param namespaceURI the namespace URI of this SOAP message's name. + * @param localPart the local part of this SOAP message's name. + */ + public void setName(String namespaceURI, String localPart) + { + setName(new QName(namespaceURI, localPart)); + } + + /** + * Sets the qualified name of this SOAP message to that constructed + * from the supplied namespace URI, local part and prefix. + * + * @param namespaceURI the namespace URI of this SOAP message's name. + * @param localPart the local part of this SOAP message's name. + * @param prefix the prefix of this SOAP message's name. + */ + public void setName(String namespaceURI, String localPart, String prefix) + { + setName(new QName(namespaceURI, localPart, prefix)); + } + + /** + * Sets the name of this SOAP message to that specified. + * + * @param name the name of this SOAP message. + */ + public void setName(QName name) + { + this.name = name; + } + + /** + * Adds a new part to the SOAP message. + * + * @param part the new part to add. + */ + public boolean addPart(MessagePart part) + { + if (part == null) + return false; + parts.add(part); + return true; + } + + /** + * Retrieves the qualified name of this SOAP message. + * + * @return the qualified name of this SOAP message. + */ + public QName getName() + { + return name; + } + + /** + * Retrieves a shallow clone of the parts of this message. + * + * @return a shallow clone of the message parts. + */ + public List getParts() + { + return new LinkedList(parts); + } + + /** + * Returns a String representation of this SOAP message. + * + * @return a textual representation. + */ + public String toString() + { + return getClass().getName() + + "[name=" + + name + + ",parts=" + + parts + + "]"; + } + +} + Index: src/nongnu/cashews/soap/SoapOperation.java =================================================================== RCS file: src/nongnu/cashews/soap/SoapOperation.java diff -N src/nongnu/cashews/soap/SoapOperation.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/soap/SoapOperation.java 19 May 2005 10:26:35 -0000 @@ -0,0 +1,258 @@ +/* SoapOperation.java -- Representation of a SOAP operation. + Copyright (C) 2005 The University of Sheffield. + + This file is part of the CASheW-s editor. + + The CASheW-s editor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. +*/ + +package nongnu.cashews.soap; + +import java.net.URI; +import java.net.URISyntaxException; + +import javax.xml.namespace.QName; + +import nongnu.cashews.language.grounding.Grounding; + +import nongnu.cashews.xml.XmlField; +import nongnu.cashews.xml.Xmlizable; + +/** + * An implementation of Grounding for the Simple + * Object Access Protocol (SOAP). SOAP operations have an + * endpoint, a namespace, an input message and an output + * message, which specify the location, naming and data + * transmission of the operation respectively. + * + * @author Andrew John Hughes (address@hidden) + * @see Grounding + */ +public class SoapOperation + implements Grounding, Xmlizable +{ + + private static final long serialVersionUID = 5826068966824453255L; + + /** + * Serialization fields which specify how to serialize this class. + */ + private static final XmlField[] serialPersistentFields + = new XmlField[] + { + new XmlField("endpoint",URI.class), + new XmlField("namespace",URI.class), + new XmlField("inputMessage",SoapMessage.class,false,true,false), + new XmlField("outputMessage",SoapMessage.class,false,true,false) + }; + + /** + * The endpoint where the operation is located. + * + * @serial the endpoint of the operation. + */ + private URI endpoint; + + /** + * The namespace of this operation. + * + * @serial the operation namespace. + */ + private URI namespace; + + /** + * The message format for the input. + * + * @serial the input message format. + */ + private SoapMessage inputMessage; + + /** + * The message format for the output. + * + * @serial the output message format. + */ + private SoapMessage outputMessage; + + /** + * Constructs a new empty operation. + */ + public SoapOperation() + { + } + + /** + * Constructs a new operation using the specified endpoint. + * The endpoint is also used as the namespace of the operation. + * + * @param endpoint the endpoint of this SOAP operation. + * @throws URISyntaxException if the supplied endpoint is not a valid URI. + */ + public SoapOperation(String endpoint) + throws URISyntaxException + { + this(endpoint, endpoint); + } + + /** + * Constructs a new operation using the specified endpoint + * and namespace. + * + * @param endpoint the endpoint of this SOAP operation. + * @param namespace the namespace of this SOAP operation. + * @throws URISyntaxException if the supplied endpoint is not a valid URI. + */ + public SoapOperation(String endpoint, String namespace) + throws URISyntaxException + { + setEndpoint(endpoint); + setNamespace(namespace); + } + + /** + * Sets the endpoint of this SOAP operation to that specified. + * + * @param endpoint the endpoint of the operation. + * @throws URISyntaxException if the supplied endpoint is not a valid URI. + */ + public void setEndpoint(String endpoint) + throws URISyntaxException + { + setEndpoint(new URI(endpoint)); + } + + /** + * Sets the endpoint of this SOAP operation to that specified. + * + * @param endpoint the endpoint of the operation. + */ + public void setEndpoint(URI endpoint) + { + this.endpoint = endpoint; + } + + /** + * Sets the namespace of this SOAP operation to that specified. + * + * @param namespace the namespace of the operation. + * @throws URISyntaxException if the supplied namespace is not a valid URI. + */ + public void setNamespace(String namespace) + throws URISyntaxException + { + setNamespace(new URI(namespace)); + } + + /** + * Sets the namespace of this SOAP operation to that specified. + * + * @param namespace the namespace of the operation. + */ + public void setNamespace(URI namespace) + { + this.namespace = namespace; + } + + /** + * Sets the input message of this SOAP operation to that specified. + * + * @param inputMessage the input message of this operation. + */ + public void setInputMessage(SoapMessage inputMessage) + { + this.inputMessage = inputMessage; + } + + /** + * Sets the output message of this SOAP operation to that specified. + * + * @param outputMessage the output message of this operation. + */ + public void setOutputMessage(SoapMessage outputMessage) + { + this.outputMessage = outputMessage; + } + + /** + * Retrieves the endpoint of this operation. + * + * @return the operation endpoint. + */ + public URI getEndpoint() + { + return endpoint; + } + + /** + * Retrieves the input message of this operation. + * + * @return the operation's input message. + */ + public SoapMessage getInputMessage() + { + return inputMessage; + } + + /** + * Returns a String representation of this SOAP operation. + * + * @return a textual representation. + */ + public String toString() + { + return getClass().getName() + + "[endpoint=" + + endpoint + + ",namespace=" + + namespace + + ",inputMessage=" + + inputMessage + + ",outputMessage=" + + outputMessage + + "]"; + } + + /** + * Returns "soapOperation" as the element name. + * + * @return soapOperation + */ + public String getElementName() + { + return "soapOperation"; + } + + /** + * Retrieves an array of QNames which specifies the namespaces to + * declare when serializing this element as XML. + * + * @return an array of QNames for namespace declaration. + */ + public QName[] getDeclaredNamespaces() + { + if (inputMessage != null) + { + return new QName[] + { + inputMessage.getName() + }; + } + else + return null; + } + +} + Index: src/nongnu/cashews/wsdl/WsdlHandler.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/wsdl/WsdlHandler.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 WsdlHandler.java --- src/nongnu/cashews/wsdl/WsdlHandler.java 13 May 2005 01:46:47 -0000 1.3 +++ src/nongnu/cashews/wsdl/WsdlHandler.java 19 May 2005 10:26:35 -0000 @@ -35,9 +35,9 @@ import javax.xml.namespace.QName; import nongnu.cashews.commons.PairMap; -import nongnu.cashews.language.grounding.MessagePart; -import nongnu.cashews.language.grounding.SoapMessage; -import nongnu.cashews.language.grounding.SoapOperation; +import nongnu.cashews.soap.MessagePart; +import nongnu.cashews.soap.SoapMessage; +import nongnu.cashews.soap.SoapOperation; import nongnu.cashews.xml.XmlBaseHandler; Index: src/nongnu/cashews/xml/Serializer.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/xml/Serializer.java,v retrieving revision 1.5 diff -u -3 -p -u -r1.5 Serializer.java --- src/nongnu/cashews/xml/Serializer.java 9 May 2005 02:36:56 -0000 1.5 +++ src/nongnu/cashews/xml/Serializer.java 19 May 2005 10:26:35 -0000 @@ -339,9 +339,9 @@ public class Serializer * @param objRoot the root to which the serialized document should be * presented. */ - public static void serializeValue(String name, Object value, - TypeMapper mapper, Document document, - Element objRoot) + public static void serializeValue(String name, T value, + TypeMapper mapper, Document document, + Element objRoot) throws IllegalAccessException { serializeValue(name, value, false, true, mapper, document, objRoot); @@ -361,19 +361,19 @@ public class Serializer * @param objRoot the root to which the serialized document should be * presented. */ - public static void serializeValue(String name, Object value, - boolean includeFieldName, - boolean includeTypeName, - TypeMapper mapper, Document document, - Element objRoot) + public static void serializeValue(String name, T value, + boolean includeFieldName, + boolean includeTypeName, + TypeMapper mapper, Document document, + Element objRoot) throws IllegalAccessException { System.out.println("field: " + name); if (value == null) return; - Class valueClazz = value.getClass(); + Class valueClazz = (Class) value.getClass(); System.out.println("value: " + value + ", " + valueClazz); - XsdType schemaType = mapper.map(valueClazz); + XsdType schemaType = mapper.map(valueClazz); if (schemaType != null) { Element element = createElement(document, name); Index: src/nongnu/cashews/xml/schema/TypeMapper.java =================================================================== RCS file: /cvsroot/cashew-s-editor/cashews/src/nongnu/cashews/xml/schema/TypeMapper.java,v retrieving revision 1.3 diff -u -3 -p -u -r1.3 TypeMapper.java --- src/nongnu/cashews/xml/schema/TypeMapper.java 13 May 2005 01:46:47 -0000 1.3 +++ src/nongnu/cashews/xml/schema/TypeMapper.java 19 May 2005 10:26:35 -0000 @@ -21,15 +21,14 @@ package nongnu.cashews.xml.schema; -import java.lang.reflect.Type; import java.net.URI; import java.util.HashMap; import java.util.Map; import javax.xml.namespace.QName; -import nongnu.cashews.xml.schema.datatypes.AnyUri; -import nongnu.cashews.xml.schema.datatypes.Int; +import nongnu.cashews.xml.schema.datatypes.XsdAnyUri; +import nongnu.cashews.xml.schema.datatypes.XsdInt; import nongnu.cashews.xml.schema.datatypes.XsdQName; import nongnu.cashews.xml.schema.datatypes.XsdString; @@ -44,30 +43,30 @@ public class TypeMapper /** * Map for the built-in XML schema datatypes. */ - private static Map> builtInTypes; + private static Map,XsdType> builtInTypes; /** * Initializer for the static map. */ static { - builtInTypes = new HashMap>(); - builtInTypes.put(URI.class, new AnyUri()); + builtInTypes = new HashMap,XsdType>(); + builtInTypes.put(URI.class, new XsdAnyUri()); builtInTypes.put(QName.class, new XsdQName()); - builtInTypes.put(Integer.class, new Int()); + builtInTypes.put(Integer.class, new XsdInt()); builtInTypes.put(String.class, new XsdString()); } /** - * Maps a Java Type to its corresponding + * Maps a Java Class to its corresponding * XSD type. * * @param type the Java type to map, or null * if no mapping exists. */ - public XsdType map(Type type) + public XsdType map(Class type) { - return builtInTypes.get(type); + return (XsdType) builtInTypes.get(type); } } Index: src/nongnu/cashews/xml/schema/datatypes/AnyUri.java =================================================================== RCS file: src/nongnu/cashews/xml/schema/datatypes/AnyUri.java diff -N src/nongnu/cashews/xml/schema/datatypes/AnyUri.java --- src/nongnu/cashews/xml/schema/datatypes/AnyUri.java 4 May 2005 22:14:05 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,52 +0,0 @@ -/* AnyUri.java -- Represents the XML schema type, xsd:anyURI. - Copyright (C) 2005 The University of Sheffield. - - This file is part of the CASheW-s editor. - - The CASheW-s editor is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The CASheW-s editor is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with The CASheW-s editor; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. -*/ - -package nongnu.cashews.xml.schema.datatypes; - -import java.net.URI; - -import nongnu.cashews.xml.schema.XsdType; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -/** - * Represents the XML schema datatype, xsd:anyURI. - * - * @author Andrew John Hughes (address@hidden) - */ -public class AnyUri - implements XsdType -{ - - /** - * Translates the supplied Java URI into a value - * of the XML schema datatype, xsd:anyURI. - * @param document the XML document to use to create the XML tree. - * @param value the URI value to translate. - * @return an XML tree node representing the type. - */ - public Node translateValue(Document document, URI value) - { - return document.createTextNode(value.toString()); - } - -} Index: src/nongnu/cashews/xml/schema/datatypes/Int.java =================================================================== RCS file: src/nongnu/cashews/xml/schema/datatypes/Int.java diff -N src/nongnu/cashews/xml/schema/datatypes/Int.java --- src/nongnu/cashews/xml/schema/datatypes/Int.java 7 May 2005 21:22:54 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,50 +0,0 @@ -/* Int.java -- Represents the XML schema type, xsd:int. - Copyright (C) 2005 The University of Sheffield. - - This file is part of the CASheW-s editor. - - The CASheW-s editor is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - The CASheW-s editor is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with The CASheW-s editor; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. -*/ - -package nongnu.cashews.xml.schema.datatypes; - -import nongnu.cashews.xml.schema.XsdType; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -/** - * Represents the XML schema datatype, xsd:int. - * - * @author Andrew John Hughes (address@hidden) - */ -public class Int - implements XsdType -{ - - /** - * Translates the supplied Java Integer into a value - * of the XML schema datatype, xsd:int. - * @param document the XML document to use to create the XML tree. - * @param value the Integer value to translate. - * @return an XML tree node representing the type. - */ - public Node translateValue(Document document, Integer value) - { - return document.createTextNode(value.toString()); - } - -} Index: src/nongnu/cashews/xml/schema/datatypes/XsdAnyUri.java =================================================================== RCS file: src/nongnu/cashews/xml/schema/datatypes/XsdAnyUri.java diff -N src/nongnu/cashews/xml/schema/datatypes/XsdAnyUri.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/xml/schema/datatypes/XsdAnyUri.java 19 May 2005 10:26:35 -0000 @@ -0,0 +1,52 @@ +/* XsdAnyUri.java -- Represents the XML schema type, xsd:anyURI. + Copyright (C) 2005 The University of Sheffield. + + This file is part of the CASheW-s editor. + + The CASheW-s editor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. +*/ + +package nongnu.cashews.xml.schema.datatypes; + +import java.net.URI; + +import nongnu.cashews.xml.schema.XsdType; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +/** + * Represents the XML schema datatype, xsd:anyURI. + * + * @author Andrew John Hughes (address@hidden) + */ +public class XsdAnyUri + implements XsdType +{ + + /** + * Translates the supplied Java URI into a value + * of the XML schema datatype, xsd:anyURI. + * @param document the XML document to use to create the XML tree. + * @param value the URI value to translate. + * @return an XML tree node representing the type. + */ + public Node translateValue(Document document, URI value) + { + return document.createTextNode(value.toString()); + } + +} Index: src/nongnu/cashews/xml/schema/datatypes/XsdInt.java =================================================================== RCS file: src/nongnu/cashews/xml/schema/datatypes/XsdInt.java diff -N src/nongnu/cashews/xml/schema/datatypes/XsdInt.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/nongnu/cashews/xml/schema/datatypes/XsdInt.java 19 May 2005 10:26:35 -0000 @@ -0,0 +1,50 @@ +/* XsdInt.java -- Represents the XML schema type, xsd:int. + Copyright (C) 2005 The University of Sheffield. + + This file is part of the CASheW-s editor. + + The CASheW-s editor is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + The CASheW-s editor is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with The CASheW-s editor; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. +*/ + +package nongnu.cashews.xml.schema.datatypes; + +import nongnu.cashews.xml.schema.XsdType; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +/** + * Represents the XML schema datatype, xsd:int. + * + * @author Andrew John Hughes (address@hidden) + */ +public class XsdInt + implements XsdType +{ + + /** + * Translates the supplied Java Integer into a value + * of the XML schema datatype, xsd:int. + * @param document the XML document to use to create the XML tree. + * @param value the Integer value to translate. + * @return an XML tree node representing the type. + */ + public Node translateValue(Document document, Integer value) + { + return document.createTextNode(value.toString()); + } + +}