diff options
author | kchong | 2005-07-12 19:03:23 +0000 |
---|---|---|
committer | kchong | 2005-07-12 19:03:23 +0000 |
commit | 2c692688d32525130ea66e1674ffe9ed2f522452 (patch) | |
tree | 23385b07402a25df019173719f17db7673bf19fe /bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core | |
parent | 0196faf7d13a8e4b9ac4a5e6f776b0311e1aac75 (diff) | |
download | webtools.webservices-20050712_1505.tar.gz webtools.webservices-20050712_1505.tar.xz webtools.webservices-20050712_1505.zip |
This commit was manufactured by cvs2svn to create tag 'v20050712_1505'.v20050712_1505
Diffstat (limited to 'bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core')
21 files changed, 0 insertions, 2378 deletions
diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/ClassEntry.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/ClassEntry.java deleted file mode 100644 index 0d08d1017..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/ClassEntry.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.command.internal.env.core.data; - -import java.util.Vector; - -public class ClassEntry -{ - public Object lastObject_; - public Vector getterList_; - public Vector setterList_; - public int order_; -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/DataFlowManager.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/DataFlowManager.java deleted file mode 100644 index 0262a5bfa..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/DataFlowManager.java +++ /dev/null @@ -1,275 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.data; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.Hashtable; -import java.util.Vector; - -import org.eclipse.wst.command.internal.provisional.env.core.common.Environment; -import org.eclipse.wst.command.internal.provisional.env.core.common.Log; -import org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry; -import org.eclipse.wst.command.internal.provisional.env.core.data.Transformer; - - -public class DataFlowManager -{ - private DataMappingRegistryImpl registry_; - private Hashtable classTable_; - private int order_; - private Environment environment_; - - public DataFlowManager( DataMappingRegistryImpl registry, Environment environment ) - { - registry_ = registry; - classTable_ = new Hashtable(); - order_ = 0; - environment_ = environment; - } - - public DataMappingRegistry getMappingRegistry() - { - return registry_; - } - - public void process( Object object ) - { - // Add this object to the classTable_ if required. - String objectType = object.getClass().getName(); - ClassEntry classEntry = (ClassEntry)classTable_.get( objectType ); - - environment_.getLog().log(Log.INFO, "data", 5004, this, "process", "Processing: " + objectType ); - - if( classEntry == null ) - { - classEntry = new ClassEntry(); - classTable_.put( objectType, classEntry ); - } - - classEntry.lastObject_ = object; - classEntry.order_ = order_++; - - // Now process the setters for this object - Vector ruleEntries = registry_.getRuleEntries( objectType ); - - if( ruleEntries != null ) - { - if( classEntry.setterList_ == null ) - { - classEntry.setterList_ = getSetterList( object ); - } - - // For each setter in this object try to find a rule. - for( int setterIndex = 0; setterIndex < classEntry.setterList_.size(); setterIndex++ ) - { - ObjectMethod currentObjectMethod = new ObjectMethod(); - Method setterMethod = (Method)classEntry.setterList_.elementAt( setterIndex ); - RuleEntry currentRuleEntry = null; - - currentObjectMethod.order = -1; - - // Find rules that match this setter. Note: there can be more than one rule - // that matches this setter. In this case we use the most recent, which is - // defined by the order field. - for( int index = 0; index < ruleEntries.size(); index++ ) - { - RuleEntry ruleEntry = (RuleEntry)ruleEntries.elementAt( index ); - - if( setterMethod.getName().equals( "set" + ruleEntry.targetProperty_ ) ) - { - // We found a setter for this rule. Now find the getter method. - // Note: getGetterMethod always returns a value, but if there is no - // getters available it will set the order to -1. - ObjectMethod getter = getGetterMethod( ruleEntry.sourceType_, ruleEntry.sourceProperty_ ); - - if( getter.order == -1 ) - { - environment_.getLog().log(Log.INFO , "data", 5005, this, "process", " >>No getter found for property: " + setterMethod.getName()); - } - - if( currentObjectMethod.order < getter.order ) - { - // We found a more recent getter. - currentObjectMethod = getter; - currentRuleEntry = ruleEntry; - } - } - } - - if( currentObjectMethod.order != -1 ) - { - invokeMethod( currentObjectMethod.object, - currentObjectMethod.method, - object, - setterMethod, - currentRuleEntry.transformer_ ); - } - else - { - environment_.getLog().log(Log.INFO, "data", 5006, this, "process", " >>No rule found for setter: " + setterMethod.getName() ); - } - } - } - } - - /** - * Find all the setters for this object and return a vector of them. - * - * @param object - * @return - */ - private Vector getSetterList( Object object ) - { - Vector result = new Vector(); - - Method[] methods = object.getClass().getMethods(); - - for( int index = 0; index < methods.length; index++ ) - { - Method method = methods[index]; - boolean isPublic = Modifier.isPublic( method.getModifiers() ); - Class returnType = method.getReturnType(); - - if( isPublic && - returnType == Void.TYPE && - method.getParameterTypes().length == 1 && - method.getName().startsWith( "set" )) - { - method.setAccessible( true ); - result.add( method ); - } - } - - return result; - } - - private ObjectMethod getGetterMethod( String sourceType, String sourceProperty ) - { - ClassEntry classEntry = (ClassEntry)classTable_.get( sourceType ); - ObjectMethod getterFound = new ObjectMethod(); - - // Indicate that there is no getter yet. - getterFound.order = -1; - - if( classEntry != null ) - { - if( classEntry.getterList_ == null ) - { - // Build the getter list. - classEntry.getterList_ = getGetterList( classEntry.lastObject_ ); - } - - for( int index = 0; index < classEntry.getterList_.size(); index++ ) - { - Method getter = (Method)classEntry.getterList_.elementAt( index ); - - if( getter.getName().equals( "get" + sourceProperty )) - { - getterFound.order = classEntry.order_; - getterFound.method = getter; - getterFound.object = classEntry.lastObject_; - break; - } - } - } - - return getterFound; - } - - private Vector getGetterList( Object object ) - { - Vector result = new Vector(); - - Method[] methods = object.getClass().getMethods(); - - for( int index = 0; index < methods.length; index++ ) - { - Method method = methods[index]; - boolean isPublic = Modifier.isPublic( method.getModifiers() ); - Class returnType = method.getReturnType(); - - if( isPublic && - returnType != Void.TYPE && - method.getParameterTypes().length == 0 && - method.getName().startsWith( "get" )) - { - method.setAccessible( true ); - result.add( method ); - } - } - - return result; - } - - private void invokeMethod( Object sourceObject, - Method sourceMethod , - Object clientObject, - Method clientMethod, - Transformer transformer) - { - Object data = null; - - try - { - data = sourceMethod.invoke( sourceObject, new Object[0] ); - } - catch( InvocationTargetException exc ) - { - exc.printStackTrace(); - // pgm Need to externalize this string. - throw new IllegalArgumentException( "Provider \"" + sourceObject.getClass().getName() + - "\" threw an exception." ); - } - catch( IllegalAccessException exc ) - { - exc.printStackTrace(); - // pgm Need to externalize this string. - throw new IllegalArgumentException( "Provider \"" + sourceObject.getClass().getName() + - "\" threw an exception." ); - } - - environment_.getLog().log(Log.INFO, "data", 5007, this, "invokeMethod "," Setting prop: " + clientMethod.getName() + " data=" + data + " from: " + sourceObject.getClass().getName() ); - - - if( transformer != null ) - { - data = transformer.transform( data ); - } - - try - { - clientMethod.invoke( clientObject, new Object[]{ data } ); - } - catch( InvocationTargetException exc ) - { - exc.printStackTrace(); - // pgm Need to externalize this string. - throw new IllegalArgumentException( "Client \"" + clientObject.getClass().getName() + - "\" threw an exception." ); - } - catch( IllegalAccessException exc ) - { - exc.printStackTrace(); - // pgm Need to externalize this string. - throw new IllegalArgumentException( "Client \"" + clientObject.getClass().getName() + - "\" threw an exception." ); - } - } - - private class ObjectMethod - { - public Object object; - public Method method; - public int order; - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/DataMappingRegistryImpl.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/DataMappingRegistryImpl.java deleted file mode 100644 index c6d34264e..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/DataMappingRegistryImpl.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.data; - -import java.util.Hashtable; -import java.util.Vector; - -import org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry; -import org.eclipse.wst.command.internal.provisional.env.core.data.Transformer; - - -public class DataMappingRegistryImpl implements DataMappingRegistry -{ - private Hashtable rulesTable_ = new Hashtable(); - - public Vector getRuleEntries( String targetType ) - { - return (Vector)rulesTable_.get( targetType ); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry#addMapping(java.lang.Class, java.lang.String, java.lang.Class, java.lang.String, org.eclipse.wst.command.internal.provisional.env.core.data.Transformer) - */ - public void addMapping( Class sourceType, String sourceProperty, - Class targetType, String targetProperty, - Transformer transformer) - { - Vector ruleEntries = (Vector)rulesTable_.get( targetType.getName() ); - RuleEntry ruleEntry = null; - - if( ruleEntries == null ) - { - ruleEntries = new Vector(); - rulesTable_.put( targetType.getName(), ruleEntries ); - } - - // Find the rule entry - for( int index = 0; index < ruleEntries.size(); index++ ) - { - RuleEntry newEntry = (RuleEntry)ruleEntries.elementAt( index ); - - if( sourceProperty.equals( newEntry.sourceProperty_ ) && - sourceType.equals( newEntry.sourceType_ ) && - targetProperty.equals( newEntry.targetProperty_ ) ) - { - // The entry already exists - ruleEntry = newEntry; - break; - } - } - - if( ruleEntry == null ) - { - // The rule didn't exist already so we will create a new one. - ruleEntry = new RuleEntry(sourceType.getName(), sourceProperty, targetProperty, transformer ); - ruleEntries.add( ruleEntry ); - } - else - { - // Just update the transformer. - ruleEntry.transformer_ = transformer; - } - } - - //ruleEntries_. -// String sourceClass = sourceType.getName(); -// String targetClass = targetType.getName(); -// Vector entries = (Vector)ruleEntries_.get( sourceClass ); -// RuleEntry ruleEntry = null; -// -// if( entries != null ) -// { -// // Check to see if this mapping already exists. -// for( int index = 0; index < entries.size(); index++ ) -// { -// RuleEntry foundEntry = (RuleEntry)entries.elementAt( index ); -// -// if( sourceProperty.equals( foundEntry.sourceProperty_ ) && -// targetType.equals( foundEntry.targetType_ ) && -// targetProperty.equals( foundEntry.targetProperty_ ) ) -// { -// ruleEntry = foundEntry; -// ruleEntry.transformer_ = transformer; -// } -// } -// -// // There is an existing vector for this sourceClass, but it didn't -// // contain this new rule so we will add it in. -// if( ruleEntry == null ) -// { -// ruleEntry = new RuleEntry( sourceProperty, targetClass, targetProperty, transformer ); -// entries.add( ruleEntry ); -// } -// } -// else -// { -// // We need to create a new vector for this sourceClass. -// entries = new Vector(); -// ruleEntry = new RuleEntry( sourceProperty, targetClass, targetProperty, transformer ); -// entries.add( ruleEntry ); -// ruleEntries_.put( sourceClass, entries ); -// } -// } - - /* (non-Javadoc) - * @see org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry#addMapping(java.lang.Class, java.lang.String, java.lang.Class) - */ - public void addMapping(Class sourceType, String sourceProperty, Class targetType) - { - addMapping( sourceType, sourceProperty, targetType, sourceProperty, null ); - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/RuleEntry.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/RuleEntry.java deleted file mode 100644 index 883523991..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/data/RuleEntry.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.data; - -import org.eclipse.wst.command.internal.provisional.env.core.data.Transformer; - -public class RuleEntry -{ - public String sourceType_; - public String sourceProperty_; - public String targetProperty_; - public Transformer transformer_; - - - public RuleEntry( String sourceType, - String sourceProperty, - String targetProperty, - Transformer transformer ) - { - sourceType_ = sourceType; - sourceProperty_ = sourceProperty; - targetProperty_ = targetProperty; - transformer_ = transformer; - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/AbstractCommandFragment.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/AbstractCommandFragment.java deleted file mode 100644 index 9f8ea47f3..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/AbstractCommandFragment.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -import org.eclipse.wst.command.internal.provisional.env.core.CommandFactory; -import org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry; - - -/** - * This class is used as the base class for other standard fragment classes. - * -**/ -public abstract class AbstractCommandFragment implements CommandFragment -{ - private CommandFactory commandFactory_; - private String id_; - private boolean doNotRunInTransaction_ = false; - - /** - * Copy constructor. - * @param fragment - */ - protected AbstractCommandFragment( AbstractCommandFragment fragment ) - { - commandFactory_ = fragment.commandFactory_; - id_ = fragment.id_; - } - - /** - * Creates a new AbstractCommandFragment. - * - * @param command the executable command for this fragment. - **/ - public AbstractCommandFragment( CommandFactory commandFactory, String id ) - { - commandFactory_ = commandFactory; - id_ = id; - } - - public String getId() - { - return id_; - } - - public void setId( String id ) - { - id_ = id; - } - - /** - * Gets executable command associated with this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFactory getCommandFactory() - { - return commandFactory_; - } - - /** - * This method is called retrieve the data mappings for this command fragment. - */ - public void registerDataMappings( DataMappingRegistry registry ) - { - // The default behaviour is not to add any entries to the registry. - } - - /** - * - * @return If the commands for this fragment should not be run within a transaction then - * this method should return true. If the fragment does not care if it is run in a transaction - * or not it should return false. - */ - public boolean doNotRunInTransaction() - { - return doNotRunInTransaction_; - } - - /** - * Sets the run in transaction property. - * @param doNotRunInTransaction - */ - public void setDoNotRunInTransaction( boolean doNotRunInTransaction ) - { - doNotRunInTransaction_ = doNotRunInTransaction; - } - - /** - * All fragments need to be cloneable. - **/ - abstract public Object clone(); - -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/BooleanFragment.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/BooleanFragment.java deleted file mode 100644 index 6379c5b3a..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/BooleanFragment.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -import org.eclipse.wst.command.internal.provisional.env.core.CommandFactory; -import org.eclipse.wst.command.internal.provisional.env.core.common.Condition; - - -/** - * This class returns either the true fragment or the false fragment - * based on the response from the condition object. -**/ -public class BooleanFragment extends AbstractCommandFragment -{ - private CommandFragment trueFragment_; - private CommandFragment falseFragment_; - private Condition condition_; - - /** - * Create a BooleanFragment with default values. - * - */ - public BooleanFragment() - { - this( null, null, new Condition() - { - public boolean evaluate() - { - return true; - } - }, - null, "" ); - } - - /** - * - * @param trueFragment The fragment chosen if the condition is true. - * @param falseFragment The fragment chosen if the condition is false. - * @param condition The condition. - */ - public BooleanFragment( CommandFragment trueFragment, - CommandFragment falseFragment, - Condition condition ) - { - this( trueFragment, falseFragment, condition, null, "" ); - } - - /** - * Creates a new BooleanFragment. - * - * @param trueFragment returned if condition is true. - * @param falseFragment returned if condition is false. - * @param condition the condition for this fragment. - * @param state the state passed to the condition. - * @param command the exectable command for this fragment. - **/ - public BooleanFragment( CommandFragment trueFragment, - CommandFragment falseFragment, - Condition condition, - CommandFactory commandFactory, - String id ) - { - super( commandFactory, id ); - - trueFragment_ = trueFragment; - falseFragment_ = falseFragment; - condition_ = condition; - } - - /** - * Copy constructor. - * @param frag - */ - protected BooleanFragment( BooleanFragment frag ) - { - this( null, - null, - frag.condition_, - frag.getCommandFactory(), - frag.getId() ); - - // Now we have to clone in the true and false - // fragments. - trueFragment_ = (CommandFragment)trueFragment_.clone(); - falseFragment_ = (CommandFragment)falseFragment_.clone(); - } - - /** - * Makes a copy of the CommandFragment. - * - * @return returns a copy of this fragment. - **/ - public Object clone() - { - return new BooleanFragment( this ); - } - - /** - * Gets the first child fragment for this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFragment getFirstSubFragment() - { - return condition_.evaluate() ? trueFragment_ : falseFragment_; - } - - /** - * Gets the next child fragment for this fragment. - * - * @return returns the next child fragment for this fragment. Returns null - * when there is no next child. - **/ - public CommandFragment getNextSubFragment( CommandFragment fragment ) - { - return null; - } - - /** - * Sets the condition. - * @param condition - */ - public void setCondition( Condition condition ) - { - condition_ = condition; - } - - /** - * Sets the true fragment. - * @param fragment - */ - public void setTrueFragment( CommandFragment fragment ) - { - trueFragment_ = fragment; - } - - /** - * Sets the false fragment. - * @param fragment - */ - public void setFalseFragment( CommandFragment fragment ) - { - falseFragment_ = fragment; - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/ChoiceFragment.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/ChoiceFragment.java deleted file mode 100644 index ab7edc07f..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/ChoiceFragment.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -import java.util.Enumeration; -import java.util.Hashtable; - -import org.eclipse.wst.command.internal.provisional.env.core.CommandFactory; -import org.eclipse.wst.command.internal.provisional.env.core.common.Evaluate; - - -/** - * This class returns a fragment from a list of fragments based - * on the object returned from the Evaluate object. -**/ -public class ChoiceFragment extends AbstractCommandFragment -{ - private Hashtable fragmentTable_; - private Evaluate evaluate_; - - /** - * Create a clone with new a new hashtable. - **/ - protected ChoiceFragment( ChoiceFragment frag ) - { - super( frag.getCommandFactory(), frag.getId() ); - - evaluate_ = frag.evaluate_; - fragmentTable_ = new Hashtable(); - - Enumeration keys = frag.fragmentTable_.keys(); - - // Clone the fragments in the table. - while( keys.hasMoreElements() ) - { - Object key = keys.nextElement(); - fragmentTable_.put( key, ((CommandFragment)frag.fragmentTable_.get(key)).clone() ); - } - } - - public ChoiceFragment( Object[] keys, - CommandFragment[] fragments ) - { - this( keys, fragments, null, null, "" ); - } - - public ChoiceFragment( Object[] keys, - CommandFragment[] fragments, - Evaluate evaluate ) - { - this( keys, fragments, evaluate, null, "" ); - } - - public void setEvaluate( Evaluate evaluate ) - { - evaluate_ = evaluate; - } - - /** - * Constructs a choice fragment. The key at index X is mapped to - * to the fragment at index X. - * - * @param keys these keys must be unique as determined by the equals method. - * They are used to identify which fragment to return. - * @param fragments these are the fragments to be returned. Null is not allowed - * as an entry in the array. - * @param evaluate the object returned by this evaluate object is used - * as the key to locate a fragment. - * @param state the state passed to evaluate. - **/ - public ChoiceFragment( Object[] keys, - CommandFragment[] fragments, - Evaluate evaluate, - CommandFactory commandFactory, - String id ) - { - super( commandFactory, id ); - - evaluate_ = evaluate; - fragmentTable_ = new Hashtable(); - - if( keys == null || fragments == null || keys.length != fragments.length ) - { - throw new IllegalArgumentException( "Bad keys or fragments." ); - } - else - { - // Create the fragment table. - for( int index = 0; index < keys.length; index++ ) - { - fragmentTable_.put( keys[index], fragments[index] ); - } - } - } - - /** - * Makes a copy of the CommandFragment. - * - * @return returns a copy of this fragment. - **/ - public Object clone() - { - return new ChoiceFragment( this ); - } - - /** - * Gets the first child fragment for this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFragment getFirstSubFragment() - { - Object key = evaluate_.evaluate(); - CommandFragment fragment = (CommandFragment)fragmentTable_.get(key); - - if( fragment == null ) - { - throw new IllegalArgumentException( "Key not found in table. Key=" + key ); - } - - return fragment; - } - - /** - * Gets the next child fragment for this fragment. - * - * @return returns the next child fragment for this fragment. Returns null - * when there is no next child. - **/ - public CommandFragment getNextSubFragment( CommandFragment fragment ) - { - return null; - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFactoryFragment.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFactoryFragment.java deleted file mode 100644 index 6991b6678..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFactoryFragment.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.command.internal.env.core.fragment; - -import java.util.Vector; - -import org.eclipse.wst.command.internal.provisional.env.core.Command; -import org.eclipse.wst.command.internal.provisional.env.core.CommandFactory; -import org.eclipse.wst.command.internal.provisional.env.core.ICommandFactory; -import org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry; - -public abstract class CommandFactoryFragment implements CommandFragment -{ - private Vector commands_; - - /** - * Subclasses should override this method and return - * an CommandFactory. - * @return - */ - public abstract ICommandFactory getICommandFactory(); - - /** - * All wizard fragments need to be cloneable. - **/ - public abstract Object clone(); - - protected CommandFactoryFragment( CommandFactoryFragment frag ) - { - commands_ = frag.commands_; - } - - public CommandFactoryFragment() - { - } - - /** - * - * @return Returns a unique identifier for this fragment. - */ - public String getId() - { - return ""; - } - - /** - * Gets executable command associated with this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFactory getCommandFactory() - { - return null; - } - - /** - * Gets the first child fragment for this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFragment getFirstSubFragment() - { - CommandFragment result = null; - - commands_ = createCommands(); - - if( commands_.size() > 0 ) - { - result = (ChildFragment)commands_.elementAt(0); - } - - return result; - } - - /** - * Gets the next child fragment for this fragment. - * - * @return returns the next child fragment for this fragment. Returns null - * when there is no next child. - **/ - public CommandFragment getNextSubFragment( CommandFragment fragment ) - { - CommandFragment result = null; - - if( commands_ != null && fragment instanceof ChildFragment ) - { - ChildFragment child = (ChildFragment)fragment; - - int index = child.index_; - - if( index != -1 ) - { - index++; - - if( index < commands_.size() ) - { - result = (CommandFragment)commands_.elementAt( index ); - } - } - } - - return result; - } - - /* - * This method is called to retrieve the data mappings for this command fragment. - */ - public void registerDataMappings( DataMappingRegistry registry ) - { - } - - /** - * - * @return If the commands for this fragment should not be run within a transaction then - * this method should return true. If the fragment does not care if it is run in a transaction - * or not it should return false. - */ - public boolean doNotRunInTransaction() - { - return false; - } - - private Vector createCommands() - { - Vector commands = new Vector(); - ICommandFactory factory = getICommandFactory(); - int index = 0; - - while( factory != null && factory.hasNext() ) - { - Command command = (Command)factory.getNextCommand(); - - commands.add( new ChildFragment( command, index++ ) ); - } - - return commands; - } - - private class ChildFragment extends SimpleFragment - { - int index_; - - public ChildFragment( Command command, int index ) - { - super( command, command.getId() ); - index_ = index; - } - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragment.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragment.java deleted file mode 100644 index e68761c80..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragment.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -import org.eclipse.wst.command.internal.provisional.env.core.CommandFactory; -import org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry; - - -/** - * This interface describes a list of interruptable commands. The - * order of this list of commands is defined by the getFirstSubFragment and - * getNextSubFragment methods. -**/ -public interface CommandFragment extends Cloneable -{ - /** - * - * @return Returns a unique identifier for this fragment. - */ - public String getId(); - - /** - * Gets executable command associated with this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFactory getCommandFactory(); - - /** - * Gets the first child fragment for this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFragment getFirstSubFragment(); - - /** - * Gets the next child fragment for this fragment. - * - * @return returns the next child fragment for this fragment. Returns null - * when there is no next child. - **/ - public CommandFragment getNextSubFragment( CommandFragment fragment ); - - /* - * This method is called to retrieve the data mappings for this command fragment. - */ - public void registerDataMappings( DataMappingRegistry registry ); - - /** - * - * @return If the commands for this fragment should not be run within a transaction then - * this method should return true. If the fragment does not care if it is run in a transaction - * or not it should return false. - */ - public boolean doNotRunInTransaction(); - - /** - * All wizard fragments need to be cloneable. - **/ - public Object clone(); -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentEngine.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentEngine.java deleted file mode 100644 index 65acace7d..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentEngine.java +++ /dev/null @@ -1,378 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -import java.util.Stack; - -import org.eclipse.wst.command.internal.env.core.data.DataFlowManager; -import org.eclipse.wst.command.internal.provisional.env.core.Command; -import org.eclipse.wst.command.internal.provisional.env.core.CommandFactory; -import org.eclipse.wst.command.internal.provisional.env.core.CommandManager; -import org.eclipse.wst.command.internal.provisional.env.core.common.Environment; -import org.eclipse.wst.command.internal.provisional.env.core.common.Log; -import org.eclipse.wst.command.internal.provisional.env.core.common.MessageUtils; -import org.eclipse.wst.command.internal.provisional.env.core.common.SimpleStatus; -import org.eclipse.wst.command.internal.provisional.env.core.common.Status; -import org.eclipse.wst.command.internal.provisional.env.core.data.DataMappingRegistry; - - - -/** - * The CommandFragmentEngine provides a convienent way to traverse CommandFragments - * and possiblity execute its associate Command. - */ -public class CommandFragmentEngine implements CommandManager -{ - private Stack commandStack_; - private FragmentListener undoFragmentListener_; - private FragmentListener nextFragmentListener_; - private FragmentListener peekFragmentListener_; - private DataFlowManager dataManager_; - private Environment environment_; - private Status lastStatus_; - - /** - * Creates a CommandFragmentEngine. - * - * @param startFragment the root fragment where traversal will begin. - * @param dataManager the data manager containing all of the data mappings. - * @param environment the environment. - */ - public CommandFragmentEngine( CommandFragment startFragment, DataFlowManager dataManager, Environment environment ) - { - SequenceFragment root = new SequenceFragment(); - root.add( startFragment ); - - commandStack_ = new Stack(); - - addToStack( root, -1 ); - addToStack( startFragment, 0 ); - - dataManager_ = dataManager; - environment_ = environment; - } - - /** - * @return returns the Data mapping registry. - */ - public DataMappingRegistry getMappingRegistry() - { - return dataManager_.getMappingRegistry(); - } - - /** - * - * @return the Status from the last Command executed. - */ - public Status getLastStatus() - { - return lastStatus_; - } - - /** - */ - public boolean isUndoEnabled() - { - return true; - } - - /** - * Sets the next fragment listener for this engine. This listener will be - * called for each fragment that is traversed in moveForwardToNextStop operation. - * - * @param listener the fragment listener. - */ - public void setNextFragmentListener( FragmentListener listener ) - { - nextFragmentListener_ = listener; - } - - /** - * Sets the next fragment listener for this engine. This listener will be - * called for each fragment that is traversed in peekForwardToNextStop operation. - * - * @param listener the fragment listener. - */ - public void setPeekFragmentListener( FragmentListener listener ) - { - peekFragmentListener_ = listener; - } - - /** - * Sets the peek fragment listener for this engine. This listener will be - * called for each fragment that is traversed in undoToLastStop operation. - * - * @param listener the fragment listener. - */ - public void setUndoFragmentListener( FragmentListener listener ) - { - undoFragmentListener_ = listener; - } - - /** - * Traverse the CommandFragments starting with the CommandFragment on the - * top of the command fragment stack. The operation does NOT change the - * command fragment stack and does not execute any command associated with - * a CommandFragment. - */ - public void peekForwardToNextStop() - { - CommandListEntry topEntry = (CommandListEntry)commandStack_.lastElement(); - int parentIndex = topEntry.parentIndex_; - CommandFragment childFragment = topEntry.fragment_; - boolean continueLoop = navigateChildFragments( childFragment, false ); - - while( parentIndex != -1 && continueLoop ) - { - CommandListEntry parentEntry = (CommandListEntry)commandStack_.elementAt( parentIndex ); - CommandFragment parentFragment = parentEntry.fragment_; - CommandFragment nextFragment = parentFragment.getNextSubFragment( childFragment ); - - if( nextFragment == null ) - { - // There are no more sibling fragments to navigate so we will pop up to the parent - // an continue navigation there. - parentIndex = parentEntry.parentIndex_; - childFragment = parentFragment; - } - else - { - if( navigateChildFragments( nextFragment, true ) ) - { - // We are continuing to navigate. This time we want to traverse the sibling - // of nextFragment. - childFragment = nextFragment; - } - else - { - // We are stopping our navigation. - continueLoop = false; - } - } - } - } - - - /** - * Traverse the CommandFragments starting with the CommandFragment on the - * top of the command fragment stack. This operation does change the - * command fragment stack and does execute any command associated with - * a CommandFragment. - */ - public void moveForwardToNextStop() - { - CommandListEntry topEntry = (CommandListEntry)commandStack_.lastElement(); - int parentIndex = topEntry.parentIndex_; - CommandFragment currentFragment = topEntry.fragment_; - boolean continueExecute = visitTop(); - CommandFragment childFragment = currentFragment.getFirstSubFragment(); - - // If the current fragment has child fragments we need to traverse these children. - while( childFragment != null && continueExecute ) - { - parentIndex = commandStack_.size() - 1; - addToStack( childFragment, parentIndex ); - continueExecute = visitTop(); - currentFragment = childFragment; - childFragment = currentFragment.getFirstSubFragment(); - } - - // The previous while loop has guaranteed that currentFragment has no - // child fragments. This while loop assumes this to be the case. - while( parentIndex != -1 && continueExecute ) - { - CommandListEntry parentEntry = (CommandListEntry)commandStack_.elementAt( parentIndex ); - CommandFragment parentFragment = parentEntry.fragment_; - CommandFragment nextFragment = null; - - if( currentFragment == null ) - { - nextFragment = parentFragment.getFirstSubFragment(); - } - else - { - nextFragment = parentFragment.getNextSubFragment( currentFragment ); - } - - if( nextFragment == null ) - { - // There are no more sibling fragments to navigate so we will pop up to the parent - // and continue navigation there. - parentIndex = parentEntry.parentIndex_; - currentFragment = parentFragment; - } - else - { - // We have a new fragment that we need to add to the top of the stack. - addToStack( nextFragment, parentIndex ); - parentIndex = commandStack_.size() - 1; - continueExecute = visitTop(); - currentFragment = null; - } - } - } - - /** - * - * @return returns true if the there is not longer any elements on the stack. Note: - * that last two entries are always left on the stack. - */ - public boolean undoToLastStop() - { - CommandListEntry topEntry = (CommandListEntry)commandStack_.lastElement(); - - // Always undo the top element. - performUndo( topEntry ); - - while( topEntry.parentIndex_ != 0 ) - { - commandStack_.pop(); - topEntry = (CommandListEntry)commandStack_.lastElement(); - - performUndo( topEntry ); - - if( topEntry.fragmentStopped_ ) - { - break; - } - } - - return topEntry.parentIndex_ == 0; - } - - private void performUndo( CommandListEntry entry ) - { - if( entry.parentIndex_ == 0 ) return; - - Command cmd = entry.command_; - - if( cmd != null && cmd.isUndoable() && !entry.beforeExecute_ ) - { - cmd.undo( environment_ ); - entry.beforeExecute_ = true; - } - - undoFragmentListener_.notify( entry.fragment_ ); - } - - private boolean navigateChildFragments( CommandFragment fragment, boolean visitCurrent ) - { - boolean continueNavigate = true; - CommandFragment childFrag = null; - - if( visitCurrent ) - { - continueNavigate = peekFragmentListener_.notify( fragment ); - dataManager_.process( fragment ); - } - - childFrag = fragment.getFirstSubFragment(); - - while( childFrag != null && continueNavigate ) - { - continueNavigate = navigateChildFragments( childFrag, true ); - childFrag = fragment.getNextSubFragment( childFrag ); - } - - return continueNavigate; - } - - private boolean visitTop() - { - CommandListEntry entry = (CommandListEntry)commandStack_.lastElement(); - boolean continueNavigate = nextFragmentListener_.notify( entry.fragment_ ); - - if( continueNavigate ) - { - // Call the setters for this fragment. - dataManager_.process( entry.fragment_ ); - - // Add any rules to the mapping registry before we execute the command. - entry.fragment_.registerDataMappings( dataManager_.getMappingRegistry() ); - - lastStatus_ = runCommand( entry ); - - if( lastStatus_.getSeverity() == Status.ERROR ) continueNavigate = false; - } - - if( !continueNavigate ) entry.fragmentStopped_ = true; - - return continueNavigate; - } - - private void addToStack( CommandFragment fragment, int parentIndex ) - { - CommandListEntry entry = new CommandListEntry( fragment, parentIndex ); - commandStack_.push( entry ); - } - - private Status runCommand( CommandListEntry entry ) - { - CommandFactory factory = entry.fragment_.getCommandFactory(); - Status status = new SimpleStatus( "" ); - - if( factory != null ) - { - Command cmd = factory.create(); - entry.command_ = cmd; - - if( cmd != null ) - { - dataManager_.process( cmd ); - - try - { - environment_.getLog().log(Log.INFO, "command", 5001, this, "runCommand", "Executing: " + cmd.getClass().getName()); - - status = cmd.execute( environment_ ); - entry.beforeExecute_ = false; - } - catch( Throwable exc ) - { - MessageUtils utils = new MessageUtils( "org.eclipse.wst.command.env.core.environment", this ); - SimpleStatus unexpectedError = new SimpleStatus("id", exc.getMessage(), Status.ERROR, exc ); - status = new SimpleStatus( "", utils.getMessage( "MSG_ERROR_UNEXPECTED_ERROR" ), new Status[]{unexpectedError} ); - environment_.getStatusHandler().reportError( status ); - } - finally - { - String message = "Ok"; - - if( status.getSeverity() == Status.ERROR ) - { - message = "Error: " + status.getMessage(); - } - - environment_.getLog().log(Log.INFO, "command", 5001, this, "runCommand", "Execution status: " + message ); - } - } - } - - return status; - } - - private class CommandListEntry - { - public CommandListEntry( CommandFragment fragment, int parentIndex ) - { - fragment_ = fragment; - parentIndex_ = parentIndex; - fragmentStopped_ = false; - beforeExecute_ = true; - } - - public Command command_; - public CommandFragment fragment_; - public int parentIndex_; - public boolean fragmentStopped_; - public boolean beforeExecute_; - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentFactory.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentFactory.java deleted file mode 100644 index a99be49b3..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -/** - * This interface provides a way to create CommandFragments. - * - */ -public interface CommandFragmentFactory -{ - /** - * - * @return returns a created CommandFragment object. - */ - public CommandFragment create(); -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentFactoryFactory.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentFactoryFactory.java deleted file mode 100644 index 0f1701c09..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/CommandFragmentFactoryFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -public interface CommandFragmentFactoryFactory -{ - /** - * The framework calls this method to get the CommandFragmentFactory - * for a particular extension. - * - * @return Creates a CommandFragmentFactory. - */ - public CommandFragmentFactory create(); -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/ExtensionFragment.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/ExtensionFragment.java deleted file mode 100644 index e293fbec3..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/ExtensionFragment.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -import java.util.Hashtable; - -import org.eclipse.wst.command.internal.env.core.registry.CommandRegistry; - - -public class ExtensionFragment extends AbstractCommandFragment -{ - private String[] ids_;; - private CommandRegistry extensionRegistry_; - private Hashtable fragments_; - - /** - * The default constructor - * - */ - public ExtensionFragment() - { - super( null, "" ); - fragments_ = new Hashtable(); - } - - /** - * Copy constructor. - * @param Fragment the fragment to copy - */ - protected ExtensionFragment( ExtensionFragment fragment ) - { - super( fragment ); - - ids_ = fragment.ids_; - extensionRegistry_ = fragment.extensionRegistry_; - fragments_ = fragment.fragments_; - } - - /** - * - * @param ids Sets the IDs for this extension fragment. - */ - public void setExtensionIds( String[] ids ) - { - ids_ = ids; - } - - /** - * - * @param registry Sets the registry for this extension fragment. - */ - public void setExtensionRegistry( CommandRegistry registry ) - { - extensionRegistry_ = registry; - } - - /** - * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#getFirstSubFragment() - */ - public CommandFragment getFirstSubFragment() - { - CommandFragmentFactoryFactory factory = extensionRegistry_.getFactoryFactory( ids_ ); - - if( factory == null ) return null; - - CommandFragment fragment = (CommandFragment)fragments_.get( factory ); - - if( fragment == null ) - { - fragment = factory.create().create(); - fragments_.put( factory, fragment ); - } - - return fragment; - } - - /** - * @see org.eclipse.wst.command.internal.env.core.fragment.CommandFragment#getNextSubFragment(org.eclipse.wst.command.internal.env.core.fragment.CommandFragment) - */ - public CommandFragment getNextSubFragment(CommandFragment fragment) - { - return null; - } - - /** - * @see java.lang.Object#clone() - */ - public Object clone() - { - return new ExtensionFragment( this ); - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/FragmentListener.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/FragmentListener.java deleted file mode 100644 index 01cd7a163..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/FragmentListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -/** - * This interface should be implement for code that needs to listen to fragments - * that are being traverse by the CommandFragmentEngine. - * - */ -public interface FragmentListener -{ - /* - * Notifies this listener that a commandFragment is being visited during - * a traversal. - */ - public boolean notify( CommandFragment commandFragment ); -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/LoopCondition.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/LoopCondition.java deleted file mode 100644 index 8c3e4d416..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/LoopCondition.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -/** - * This interface can be used when a conditional object needs to be returned. -**/ -public interface LoopCondition -{ - /** - * Evaluates a loop condition. - * - * @param loop the loop fragment that is being evaluated. - * @param fragment the child fragment of the loop - * under evaluation. Note: fragment can be null. - * @return returns an object based on some evaluated condition. - **/ - public boolean evaluate( LoopFragment loop, CommandFragment fragment ); -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/LoopFragment.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/LoopFragment.java deleted file mode 100644 index 7d41fc13d..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/LoopFragment.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -import org.eclipse.wst.command.internal.provisional.env.core.CommandFactory; -import org.eclipse.wst.command.internal.provisional.env.core.common.RangeVector; - - -/** - * This class returns a dynamically determined number of - * fragments. This loop will return the fragment parameter - * as long as the stopCondition evaluates to false. Otherwise, - * null is returned. -**/ -public class LoopFragment extends AbstractCommandFragment -{ - private LoopCondition stopCondition_; - private CommandFragment fragment_; - private RangeVector fragmentHistory_; - - /** - * Copy contructor for this fragment. - **/ - protected LoopFragment( LoopFragment fragment ) - { - this( fragment.fragment_, - fragment.stopCondition_, - fragment.getCommandFactory(), - fragment.getId() ); - } - - public LoopFragment( CommandFragment fragment, - LoopCondition stopCondition ) - { - this( fragment, stopCondition, null, "" ); - } - - /** - * @param fragment the fragment that will be returned by the loop. - * @param stopCondition when false the fragment will be returned, - * otherwise null is returned. - * @param state the state passed to the condition. - * @param command the executable command for this fragment. - **/ - public LoopFragment( CommandFragment fragment, - LoopCondition stopCondition, - CommandFactory commandFactory, - String id ) - { - super( commandFactory, id ); - - fragment_ = fragment; - stopCondition_ = stopCondition; - fragmentHistory_ = new RangeVector(); - } - - /** - * Makes a copy of the CommandFragment. - * - * @return returns a copy of this fragment. - **/ - public Object clone() - { - return new LoopFragment( this ); - } - - /** - * Returns the index of the fragment - * - * @param fragment the fragment to search. - * @return the index of this fragment. - **/ - public int indexOf( CommandFragment fragment ) - { - return fragmentHistory_.indexOf( fragment ); - } - - - /** - * Gets the first child fragment for this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFragment getFirstSubFragment() - { - return getNextSubFragment( null ); - } - - /** - * Gets the next child fragment for this fragment. - * - * @return returns the next child fragment for this fragment. Returns null - * when there is no next child. - **/ - public CommandFragment getNextSubFragment( CommandFragment frag ) - { - CommandFragment nextFrag = null; - - if( stopCondition_.evaluate( this, frag ) ) - { - // The stop condition has been met. - // Do nothing. - } - else - { - int fragIndex = indexOf( frag ); - - // Note: when fragment == null the fragIndex - // should be -1. Therefore, if there - // is already a first fragment in - // fragmentHistory that will be returned. - if( fragIndex + 1 < fragmentHistory_.size() ) - { - // We have a copy of the fragment already. - nextFrag = (CommandFragment)(fragmentHistory_.elementAt( fragIndex + 1 )); - } - else - { - nextFrag = (CommandFragment)(fragment_.clone()); - fragmentHistory_.add( nextFrag ); - } - } - - return nextFrag; - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/SequenceFragment.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/SequenceFragment.java deleted file mode 100644 index 0abcb355d..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/SequenceFragment.java +++ /dev/null @@ -1,133 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -import java.util.Arrays; -import java.util.List; -import java.util.Vector; - -import org.eclipse.wst.command.internal.provisional.env.core.CommandFactory; - - -/** - * This class implements a sequence of CommandFragments. -**/ -public class SequenceFragment extends AbstractCommandFragment -{ - private List fragmentList_; - - protected SequenceFragment( SequenceFragment frag ) - { - super( frag.getCommandFactory(), frag.getId() ); - - fragmentList_ = new Vector(); - - for( int index = 0; index < frag.fragmentList_.size(); index++ ) - { - Object newFrag = ((CommandFragment)frag.fragmentList_.get(index)).clone(); - fragmentList_.add( newFrag ); - } - } - - public SequenceFragment( CommandFragment[] fragments, - CommandFactory commandFactory, - String id ) - { - super( commandFactory, id ); - - if( fragments != null ) - { - fragmentList_ = Arrays.asList( fragments ); - } - else - { - fragmentList_ = new Vector(); - } - } - - public SequenceFragment() - { - super( null, "" ); - - fragmentList_ = new Vector(); - } - - /** - * Appends a fragment to the sequence. - **/ - public void add( CommandFragment fragment ) - { - fragmentList_.add( fragment ); - } - - /** - * Makes a copy of the CommandFragment. - * - * @return returns a copy of this fragment. - **/ - public Object clone() - { - return new SequenceFragment( this ); - } - - /** - * Gets the first child fragment for this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFragment getFirstSubFragment() - { - CommandFragment fragment = null; - - if( fragmentList_ == null || fragmentList_.size() == 0 ) - { - fragment = null; - } - else - { - fragment = (CommandFragment)( fragmentList_.get(0) ); - } - - return fragment; - } - - /** - * Gets the next child fragment for this fragment. - * - * @return returns the next child fragment for this fragment. Returns null - * when there is no next child. - **/ - public CommandFragment getNextSubFragment( CommandFragment fragment ) - { - int index = fragmentList_.indexOf( fragment ); - - if( index == -1 ) - { - throw new IllegalArgumentException( "Fragment not found in sequence."); - } - else - { - index++; - - if( index >= fragmentList_.size() ) - { - // There is nothing following this fragment so return null; - return null; - } - else - { - // Return the next fragment. - return (CommandFragment)(fragmentList_.get( index )); - } - } - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/SimpleFragment.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/SimpleFragment.java deleted file mode 100644 index 934857b5d..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/fragment/SimpleFragment.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.fragment; - -import org.eclipse.wst.command.internal.provisional.env.core.Command; -import org.eclipse.wst.command.internal.provisional.env.core.CommandFactory; - -/** - * This class implements an empty of WizardFragment. -**/ -public class SimpleFragment extends AbstractCommandFragment -{ - public SimpleFragment() - { - this( (CommandFactory)null, "" ); - } - - public SimpleFragment( String id ) - { - this( (CommandFactory)null, id ); - } - - public SimpleFragment( final Command command, String id ) - { - super( new CommandFactory() - { - public Command create() - { - return command; - } - }, id ); - } - - public SimpleFragment( CommandFactory commandFactory, String id ) - { - super( commandFactory, id ); - } - - /** - * Copy constructor for fragment. - **/ - protected SimpleFragment( SimpleFragment fragment ) - { - super( fragment.getCommandFactory(), fragment.getId() ); - } - - /** - * All wizard fragments need to be cloneable. - **/ - public Object clone() - { - return new SimpleFragment( this ); - } - - - /** - * Gets the first child fragment for this fragment. - * - * @return returns the first child fragment for this fragment. Returns - * null when there is no first child. - **/ - public CommandFragment getFirstSubFragment(){ return null; } - - /** - * Gets the next child fragment for this fragment. - * Since this is a simple fragment, there is no next fragment - * so we will always return null. - * - * @return returns the next child fragment for this fragment. Returns null - * when there is no next child. - **/ - public CommandFragment getNextSubFragment( CommandFragment fragment ){ return null; } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/registry/CommandRegistry.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/registry/CommandRegistry.java deleted file mode 100644 index 86f4829b5..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/registry/CommandRegistry.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.registry; - -import org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentFactoryFactory; - -/** - * This interface provides a way to create a CommandFragmentFactoryFactory - * from an array of ids. - * - */ -public interface CommandRegistry -{ - /** - * Creates a CommandFragmentFactoryFactory from an array of ids. - * - * @param ids the ids. - * @return the CommandFragmentFactoryFactory object. - */ - public CommandFragmentFactoryFactory getFactoryFactory( String[] ids ); -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/uri/file/FileScheme.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/uri/file/FileScheme.java deleted file mode 100644 index 2dd75001c..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/uri/file/FileScheme.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.uri.file; - -import java.net.URL; - -import org.eclipse.wst.command.internal.provisional.env.core.uri.RelativeScheme; -import org.eclipse.wst.command.internal.provisional.env.core.uri.RelativeURI; -import org.eclipse.wst.command.internal.provisional.env.core.uri.URI; - - -public class FileScheme extends RelativeScheme -{ - /* (non-Javadoc) - * @see org.eclipse.env.uri.URIScheme#isValid(org.eclipse.env.uri.URI) - */ - public boolean isValid(URI uri) - { - return uri.toString().startsWith( "file:" ); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URIScheme#newURI(java.lang.String) - */ - public URI newURI(String uri) - { - String newURI = null; - - if( uri.startsWith( "file:") ) - { - // The file protocol has been specified so keep it as is. - newURI = uri; - } - else if( uri.startsWith( "/") ) - { - // The file scheme has not been specified so we will add it. - newURI = "file:" + uri; - } - - if( newURI == null ) - { - return new RelativeURI( uri ); - } - else - { - return new FileURI( newURI ); - } - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URIScheme#newURI(org.eclipse.env.uri.URI) - */ - public URI newURI(URI uri) - { - return new FileURI( uri.toString() ); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URIScheme#newURI(java.net.URL) - */ - public URI newURI(URL url) - { - return new FileURI( url.toString() ); - } -} diff --git a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/uri/file/FileURI.java b/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/uri/file/FileURI.java deleted file mode 100644 index 179cbd95a..000000000 --- a/bundles/org.eclipse.wst.command.env.core/src/org/eclipse/wst/command/internal/env/core/uri/file/FileURI.java +++ /dev/null @@ -1,271 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.command.internal.env.core.uri.file; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Vector; - -import org.eclipse.wst.command.internal.provisional.env.core.common.SimpleStatus; -import org.eclipse.wst.command.internal.provisional.env.core.common.Status; -import org.eclipse.wst.command.internal.provisional.env.core.uri.RelativeURI; -import org.eclipse.wst.command.internal.provisional.env.core.uri.URI; -import org.eclipse.wst.command.internal.provisional.env.core.uri.URIException; -import org.eclipse.wst.command.internal.provisional.env.core.uri.URIFilter; -import org.eclipse.wst.command.internal.provisional.env.core.uri.URIScheme; - - -public class FileURI extends RelativeURI -{ - private File file_ = null; - - public FileURI( String uri ) - { - super( uri ); - - if( getURIScheme().isValid( this ) ) - { - file_ = new File( uri.substring( 5, uri.length() ) ); - } - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#asFile() - */ - public File asFile() - { - return file_; - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#erase() - */ - public void erase() throws URIException - { - deleteFile( file_ ); - } - - private void deleteFile( File file ) - { - if( file.isDirectory() ) - { - File[] children = file.listFiles(); - - for( int index = 0; index < children.length; index++ ) - { - File child = children[index]; - - if( child.isDirectory() ) - { - deleteFile( child ); - } - else - { - child.delete(); - } - } - } - - file.delete(); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#getInputStream() - */ - public InputStream getInputStream() throws URIException - { - FileInputStream stream = null; - - try - { - File parent = file_.getParentFile(); - parent.mkdirs(); - - stream = new FileInputStream( file_ ); - } - catch( IOException exc ) - { - Status status = new SimpleStatus( "", exc.getMessage(), Status.ERROR, exc ); - throw new URIException( status, this ); - } - - return stream; - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#getOutputStream() - */ - public OutputStream getOutputStream() throws URIException - { - FileOutputStream stream = null; - - try - { - File parent = file_.getParentFile(); - parent.mkdirs(); - - stream = new FileOutputStream( file_ ); - } - catch( IOException exc ) - { - Status status = new SimpleStatus( "", exc.getMessage(), Status.ERROR, exc ); - throw new URIException( status, this ); - } - - return stream; - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#getURIScheme() - */ - public URIScheme getURIScheme() - { - return new FileScheme(); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#isAvailableAsFile() - */ - public boolean isAvailableAsFile() - { - return file_ != null; - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#isAvailableAsURL() - */ - public boolean isAvailableAsURL() - { - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#isLeaf() - */ - public boolean isLeaf() - { - return file_.isFile(); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#isPresent() - */ - public boolean isPresent() - { - return file_.exists(); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#isReadable() - */ - public boolean isReadable() - { - return file_.canRead(); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#isWritable() - */ - public boolean isWritable() - { - return file_.canWrite(); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#list() - */ - public URI[] list() throws URIException - { - File[] children = file_.listFiles(); - URI[] URIs = new URI[0]; - - if( children != null ) - { - int length = children.length; - - URIs = new URI[length]; - - for( int index = 0; index < length; index++ ) - { - URIs[index] = new FileURI( "file:" + children[index].getAbsolutePath() ); - } - } - - return URIs; - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#list(org.eclipse.env.uri.URIFilter) - */ - public URI[] list(URIFilter uriFilter) throws URIException - { - File[] children = file_.listFiles(); - int length = children == null ? 0 : children.length; - Vector URIs = new Vector(); - - for( int index = 0; index < length; index++ ) - { - URI newURI = new FileURI( "file:" + children[index].getAbsolutePath() ); - - if( uriFilter.accepts( newURI) ) - { - URIs.add( newURI ); - } - } - - return (URI[])URIs.toArray( new URI[0] ); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#rename(org.eclipse.env.uri.URI) - */ - public void rename(URI newURI) throws URIException - { - uri_ = newURI.toString(); - file_.renameTo( new File( uri_ ) ); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#touchFolder() - */ - public void touchFolder() throws URIException - { - file_.mkdirs(); - } - - /* (non-Javadoc) - * @see org.eclipse.env.uri.URI#touchLeaf() - */ - public void touchLeaf() throws URIException - { - try - { - // Ensure that the parent folders are created. - File parent = file_.getParentFile(); - parent.mkdirs(); - - file_.createNewFile(); - } - catch( IOException exc ) - { - Status status = new SimpleStatus( "", exc.getMessage(), Status.ERROR, exc ); - throw new URIException( status, this ); - } - } - - private class Dummy - { - } -} |