Save This Page
Home » jdo2-model-2.3-ea-src » org.apache.jdo.model.jdo » [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   
   18   package org.apache.jdo.model.jdo;
   19   
   20   /**
   21    * This interface provides constants denoting JDO specific 
   22    * modifiers for fields of a persistence-capable class.
   23    *
   24    * @author Michael Bouschen
   25    */
   26   public class PersistenceModifier 
   27   {
   28       /** Constant representing an unspecified field modifier */
   29       public static final int UNSPECIFIED = 0;
   30   
   31       /** Constant representing a none field modifier.  */
   32       public static final int NONE = 1;
   33   
   34       /** Constant representing a transactional field modifier. */
   35       public static final int TRANSACTIONAL = 2;
   36   
   37       /** Constant representing a persistence field modifier. */
   38       public static final int PERSISTENT  = 4;
   39   
   40       /** Constant representing a possibly persistence field modifier. */
   41       public static final int POSSIBLY_PERSISTENT  = 8;
   42   
   43       /**
   44        * Returns a string representation of the specified persistence modifer. 
   45        * @param persistenceModifier the persistence modifer, one of  
   46        * {@link #UNSPECIFIED}, {@link #NONE}, {@link #PERSISTENT},
   47        * {@link #TRANSACTIONAL}, or {@link #POSSIBLY_PERSISTENT}.
   48        * @return the string representation of the PersistenceModifer constant
   49        */
   50       public static String toString(int persistenceModifier) 
   51       {
   52           switch (persistenceModifier) {
   53           case NONE :
   54               return "none"; //NOI18N
   55           case TRANSACTIONAL :
   56               return "transactional"; //NOI18N
   57           case PERSISTENT:
   58               return "persistent"; //NOI18N
   59           case POSSIBLY_PERSISTENT:
   60               return "possibly-persistent"; //NOI18N
   61           default:
   62               return "UNSPECIFIED"; //NOI18N
   63           }
   64       }
   65       
   66       /**
   67        * Returns the PersistenceModifier constant for the specified string.
   68        * @param persistenceModifier the string representation of the persistence 
   69        * modifer
   70        * @return the persistence modifer, one of {@link #UNSPECIFIED}, 
   71        * {@link #NONE}, {@link #PERSISTENT} or {@link #TRANSACTIONAL}
   72        **/
   73       public static int toPersistenceModifier(String persistenceModifier)
   74       {
   75           if ((persistenceModifier == null) || (persistenceModifier.length() == 0))
   76               return UNSPECIFIED;
   77    
   78           if ("none".equals(persistenceModifier)) //NOI18N
   79               return NONE;
   80           else if ("transactional".equals(persistenceModifier)) //NOI18N
   81               return TRANSACTIONAL;
   82           else if ("persistent".equals(persistenceModifier)) //NOI18N
   83               return PERSISTENT;
   84           else if ("possibly-persistent".equals(persistenceModifier)) //NOI18N
   85               return POSSIBLY_PERSISTENT;
   86           else
   87               return UNSPECIFIED;
   88       }
   89   }

Save This Page
Home » jdo2-model-2.3-ea-src » org.apache.jdo.model.jdo » [javadoc | source]