Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel.interactive.action » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.pdfbox.pdmodel.interactive.action;
   18   
   19   import org.apache.pdfbox.cos.COSDictionary;
   20   
   21   import org.apache.pdfbox.pdmodel.interactive.action.type.PDAction;
   22   import org.apache.pdfbox.pdmodel.interactive.action.type.PDActionGoTo;
   23   import org.apache.pdfbox.pdmodel.interactive.action.type.PDActionJavaScript;
   24   import org.apache.pdfbox.pdmodel.interactive.action.type.PDActionLaunch;
   25   import org.apache.pdfbox.pdmodel.interactive.action.type.PDActionRemoteGoTo;
   26   import org.apache.pdfbox.pdmodel.interactive.action.type.PDActionURI;
   27   
   28   /**
   29    * This class will take a dictionary and determine which type of action to create.
   30    *
   31    * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
   32    * @version $Revision: 1.5 $
   33    */
   34   public class PDActionFactory
   35   {
   36       /**
   37        * Utility Class.
   38        */
   39       private PDActionFactory()
   40       {
   41           //utility class
   42       }
   43   
   44       /**
   45        * This will create the correct type of action based on the type specified
   46        * in the dictionary.
   47        *
   48        * @param action An action dictionary.
   49        *
   50        * @return An action of the correct type.
   51        */
   52       public static PDAction createAction( COSDictionary action )
   53       {
   54           PDAction retval = null;
   55           if( action != null )
   56           {
   57               String type = action.getNameAsString( "S" );
   58               if( PDActionJavaScript.SUB_TYPE.equals( type ) )
   59               {
   60                   retval = new PDActionJavaScript( action );
   61               }
   62               else if( PDActionGoTo.SUB_TYPE.equals( type ) )
   63               {
   64                   retval = new PDActionGoTo( action );
   65               }
   66               else if( PDActionLaunch.SUB_TYPE.equals( type ) )
   67               {
   68                   retval = new PDActionLaunch( action );
   69               }
   70               else if( PDActionRemoteGoTo.SUB_TYPE.equals( type ) )
   71               {
   72                   retval = new PDActionRemoteGoTo( action );
   73               }
   74               else if( PDActionURI.SUB_TYPE.equals( type ) )
   75               {
   76                   retval = new PDActionURI( action );
   77               }
   78           }
   79           return retval;
   80       }
   81   
   82   }

Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel.interactive.action » [javadoc | source]