[jboss-cvs] jboss-portal/forums/src/main/org/jboss/portlet/forums/command ...

Julien Viet julien at jboss.com
Sun Aug 20 19:17:37 EDT 2006


  User: julien  
  Date: 06/08/20 19:17:37

  Added:       forums/src/main/org/jboss/portlet/forums/command            
                        AbstractCommand.java ActionCommand.java
                        AttributeType.java Command.java
                        CommandConstants.java CommandException.java
                        CompositeCommand.java Configurator.java
                        EmptyConfigurator.java
                        NoSuchAttachmentException.java
                        ReflectedConfigurator.java
                        UnexpectedCommandException.java
  Log:
  move command framework for forums into the forums module
  
  Revision  Changes    Path
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/AbstractCommand.java
  
  Index: AbstractCommand.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  import org.apache.log4j.Logger;
  
  /**
   * @author <a href="theute at users.sourceforge.net">Thomas Heute</a>
   * $Revision: 1.1 $
   */
  public abstract class AbstractCommand
        implements Command, CommandConstants
  {
  
     protected Logger log = Logger.getLogger(getClass());
  
     private final ReflectedConfigurator configurator = new ReflectedConfigurator(this);
  
     public Configurator getConfigurator()
     {
        return configurator;
     }
  
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/ActionCommand.java
  
  Index: ActionCommand.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  import org.jboss.portlet.forums.command.Command;
  import org.jboss.portlet.JBossActionRequest;
  import org.jboss.portlet.JBossActionResponse;
  
  /**
   * A command executed during the action request of a portlet.
   *
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public abstract class ActionCommand implements Command
  {
  
     private final JBossActionRequest request;
     private final JBossActionResponse response;
  
     protected ActionCommand(JBossActionRequest request, JBossActionResponse response)
     {
        if (request == null)
        {
           throw new IllegalArgumentException("Request cannot be null");
        }
        if (response == null)
        {
           throw new IllegalArgumentException("Response cannot be null");
        }
        this.request = request;
        this.response = response;
     }
  
     public JBossActionRequest getRequest()
     {
        return request;
     }
  
     public JBossActionResponse getResponse()
     {
        return response;
     }
  
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/AttributeType.java
  
  Index: AttributeType.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  /**
   * A type safe key for the command configuration.
   *
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class AttributeType
  {
  
     private final String name;
  
     protected AttributeType(String name)
     {
        if (name == null)
        {
           throw new IllegalArgumentException("Name cannot be null");
        }
        this.name = name;
     }
  
     public String getName()
     {
        return name;
     }
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/Command.java
  
  Index: Command.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  import org.jboss.portlet.forums.command.result.Result;
  
  /**
   * A business command.
   *
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public interface Command
  {
     /**
      * Execute the real business job.
      */
     Result execute() throws CommandException;
  
     /**
      * Returns the command configurator.
      */
     Configurator getConfigurator();
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/CommandConstants.java
  
  Index: CommandConstants.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  import org.jboss.portlet.forums.command.result.ImmutableResult;
  import org.jboss.portlet.forums.command.result.ResultType;
  
  /**
   * @author <a href="theute at users.sourceforge.net">Thomas Heute</a>
   * $Revision: 1.1 $
   */
  public interface CommandConstants
  {
     ResultType TYPE_COMPOSITE = new ImmutableResult("TYPE_COMPOSITE");
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/CommandException.java
  
  Index: CommandException.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class CommandException extends Exception
  {
     /** The serialVersionUID */
     private static final long serialVersionUID = -3088751508628488782L;
  
     public CommandException()
     {
     }
  
     public CommandException(String message)
     {
        super(message);
     }
  
     public CommandException(String message, Throwable cause)
     {
        super(message, cause);
     }
  
     public CommandException(Throwable cause)
     {
        super(cause);
     }
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/CompositeCommand.java
  
  Index: CompositeCommand.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  import java.util.Iterator;
  import java.util.LinkedList;
  
  import org.jboss.portlet.forums.command.result.Result;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class CompositeCommand
     implements Command
  {
  
     private final LinkedList list = new LinkedList();
  
     public void add(Command cmd)
     {
        list.add(cmd);
     }
  
     public Configurator getConfigurator()
     {
        return EmptyConfigurator.EMPTY_CONFIGURATOR;
     }
  
     public Iterator iterator()
     {
        return list.iterator();
     }
  
     public Result execute()
     {
        throw new RuntimeException("Cannot be executed directly");
     }
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/Configurator.java
  
  Index: Configurator.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public interface Configurator
  {
     boolean contains(AttributeType attribute);
  
     void setObject(AttributeType attribute, Object value) throws NoSuchAttachmentException;
     void setInt(AttributeType attribute, int value) throws NoSuchAttachmentException;
     void setBoolean(AttributeType attribute, boolean value) throws NoSuchAttachmentException;
     void setFloat(AttributeType attribute, float value) throws NoSuchAttachmentException;
     void setLong(AttributeType attribute, long value) throws NoSuchAttachmentException;
     void setDouble(AttributeType attribute, double value) throws NoSuchAttachmentException;
     void setChar(AttributeType attribute, char value) throws NoSuchAttachmentException;
     void setShort(AttributeType attribute, short value) throws NoSuchAttachmentException;
     void setByte(AttributeType attribute, byte value) throws NoSuchAttachmentException;
  
     Object getObject(AttributeType attribute) throws NoSuchAttachmentException;
     int getInt(AttributeType attribute) throws NoSuchAttachmentException;
     boolean getBoolean(AttributeType attribute) throws NoSuchAttachmentException;
     float getFloat(AttributeType attribute) throws NoSuchAttachmentException;
     long getLong(AttributeType attribute) throws NoSuchAttachmentException;
     double getDouble(AttributeType attribute) throws NoSuchAttachmentException;
     char getChar(AttributeType attribute) throws NoSuchAttachmentException;
     short getShort(AttributeType attribute) throws NoSuchAttachmentException;
     byte getByte(AttributeType attribute) throws NoSuchAttachmentException;
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/EmptyConfigurator.java
  
  Index: EmptyConfigurator.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class EmptyConfigurator implements Configurator
  {
  
     public static final EmptyConfigurator EMPTY_CONFIGURATOR = new EmptyConfigurator();
  
     private EmptyConfigurator()
     {
     }
  
     public boolean contains(AttributeType attribute)
     {
        return false;
     }
  
     public void setObject(AttributeType attribute, Object value) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public void setInt(AttributeType attribute, int value) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public void setBoolean(AttributeType attribute, boolean value) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public void setFloat(AttributeType attribute, float value) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public void setLong(AttributeType attribute, long value) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public void setDouble(AttributeType attribute, double value) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public void setChar(AttributeType attribute, char value) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public void setShort(AttributeType attribute, short value) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public void setByte(AttributeType attribute, byte value) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public Object getObject(AttributeType attribute) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public int getInt(AttributeType attribute) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public boolean getBoolean(AttributeType attribute) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public float getFloat(AttributeType attribute) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public long getLong(AttributeType attribute) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public double getDouble(AttributeType attribute) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public char getChar(AttributeType attribute) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public short getShort(AttributeType attribute) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  
     public byte getByte(AttributeType attribute) throws NoSuchAttachmentException
     {
        throw new NoSuchAttachmentException();
     }
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/NoSuchAttachmentException.java
  
  Index: NoSuchAttachmentException.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  /**
   * Signal that an attachment cannot be found.
   *
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class NoSuchAttachmentException extends RuntimeException
  {
  
     /** The serialVersionUID */
     private static final long serialVersionUID = -8928758813193855439L;
  
     public NoSuchAttachmentException()
     {
     }
  
     public NoSuchAttachmentException(String message)
     {
        super(message);
     }
  
     public NoSuchAttachmentException(String message, Throwable cause)
     {
        super(message, cause);
     }
  
     public NoSuchAttachmentException(Throwable cause)
     {
        super(cause);
     }
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/ReflectedConfigurator.java
  
  Index: ReflectedConfigurator.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  import java.lang.reflect.Field;
  
  import org.apache.log4j.Logger;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class ReflectedConfigurator implements Configurator
  {
  
     private static final Logger log = Logger.getLogger(ReflectedConfigurator.class);
     private final Object target;
  
     public ReflectedConfigurator(Object target)
     {
        if (target == null)
        {
           throw new IllegalArgumentException("Target cannot be null");
        }
        this.target = target;
     }
  
     private Field getTargetField(String name) throws NoSuchFieldException
     {
        return getClass().getField(name);
     }
  
     public boolean contains(AttributeType attribute)
     {
        try
        {
           getClass().getField(attribute.getName());
           return true;
        }
        catch(NoSuchFieldException ignore)
        {
        }
        catch(SecurityException ignore)
        {
        }
        return false;
     }
  
     public void setObject(AttributeType attribute, Object value) throws NoSuchAttachmentException
     {
        try
        {
           getTargetField(attribute.getName()).set(target, value);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public void setInt(AttributeType attribute, int value) throws NoSuchAttachmentException
     {
        try
        {
           getTargetField(attribute.getName()).setInt(target, value);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public void setBoolean(AttributeType attribute, boolean value) throws NoSuchAttachmentException
     {
        try
        {
           getTargetField(attribute.getName()).setBoolean(target, value);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public void setFloat(AttributeType attribute, float value) throws NoSuchAttachmentException
     {
        try
        {
           getTargetField(attribute.getName()).setFloat(target, value);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public void setLong(AttributeType attribute, long value) throws NoSuchAttachmentException
     {
        try
        {
           getTargetField(attribute.getName()).setLong(target, value);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public void setDouble(AttributeType attribute, double value) throws NoSuchAttachmentException
     {
        try
        {
           getTargetField(attribute.getName()).setDouble(target, value);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public void setChar(AttributeType attribute, char value) throws NoSuchAttachmentException
     {
        try
        {
           getTargetField(attribute.getName()).setChar(target, value);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public void setShort(AttributeType attribute, short value) throws NoSuchAttachmentException
     {
        try
        {
           getTargetField(attribute.getName()).setShort(target, value);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public void setByte(AttributeType attribute, byte value) throws NoSuchAttachmentException
     {
        try
        {
           getTargetField(attribute.getName()).setByte(target, value);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public final Object getObject(AttributeType attribute) throws NoSuchAttachmentException
     {
        try
        {
           return getTargetField(attribute.getName()).get(target);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public final int getInt(AttributeType attribute) throws NoSuchAttachmentException
     {
        try
        {
           return getTargetField(attribute.getName()).getInt(target);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public final boolean getBoolean(AttributeType attribute) throws NoSuchAttachmentException
     {
        try
        {
           return getTargetField(attribute.getName()).getBoolean(target);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public final float getFloat(AttributeType attribute) throws NoSuchAttachmentException
     {
        try
        {
           return getTargetField(attribute.getName()).getFloat(target);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public final long getLong(AttributeType attribute) throws NoSuchAttachmentException
     {
        try
        {
           return getTargetField(attribute.getName()).getLong(target);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public final double getDouble(AttributeType attribute) throws NoSuchAttachmentException
     {
        try
        {
           return getTargetField(attribute.getName()).getDouble(target);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public final char getChar(AttributeType attribute) throws NoSuchAttachmentException
     {
        try
        {
           return getTargetField(attribute.getName()).getChar(target);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public final short getShort(AttributeType attribute) throws NoSuchAttachmentException
     {
        try
        {
           return getTargetField(attribute.getName()).getShort(target);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  
     public final byte getByte(AttributeType attribute) throws NoSuchAttachmentException
     {
        try
        {
           return getTargetField(attribute.getName()).getByte(target);
        }
        catch (IllegalAccessException e)
        {
           throw new NoSuchAttachmentException(e);
        }
        catch (NoSuchFieldException e)
        {
           throw new NoSuchAttachmentException(e);
        }
     }
  }
  
  
  
  1.1      date: 2006/08/20 23:17:37;  author: julien;  state: Exp;jboss-portal/forums/src/main/org/jboss/portlet/forums/command/UnexpectedCommandException.java
  
  Index: UnexpectedCommandException.java
  ===================================================================
  /*
  * JBoss, Home of Professional Open Source
  * Copyright 2005, JBoss Inc., and individual contributors as indicated
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software 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
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
  package org.jboss.portlet.forums.command;
  
  /**
   * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
   * @version $Revision: 1.1 $
   */
  public class UnexpectedCommandException extends CommandException
  {
     /** The serialVersionUID */
     private static final long serialVersionUID = -2140160435848799779L;
  
     public UnexpectedCommandException()
     {
     }
  
     public UnexpectedCommandException(String message)
     {
        super(message);
     }
  
     public UnexpectedCommandException(String message, Throwable cause)
     {
        super(message, cause);
     }
  
     public UnexpectedCommandException(Throwable cause)
     {
        super(cause);
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list