Save This Page
Home » jdo2-model-2.3-ea-src » org.apache.jdo.impl.model.jdo.caching » [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.impl.model.jdo.caching;
   19   
   20   import org.apache.jdo.model.java.JavaType;
   21   import org.apache.jdo.model.jdo.JDORelationship;
   22   import org.apache.jdo.impl.model.jdo.JDOMapImplDynamic;
   23   
   24   /**
   25    * An instance of this class represents the JDO relationship metadata 
   26    * (the treatment of keys and values) of a map relationship field.  
   27    * This caching implementation caches any calulated value to avoid
   28    * re-calculating it if it is requested again. 
   29    *
   30    * @author Michael Bouschen
   31    * @since 1.1
   32    * @version 2.0
   33    */
   34   public class JDOMapImplCaching extends JDOMapImplDynamic {
   35   
   36       /** 
   37        * Get the mappedBy relationship. If there is no mappedBy relationship
   38        * set, the method checks the mappedBy name as specified in the declaring
   39        * field and resolves the relationship. The method returns
   40        * <code>null</code> if there is no mappedBy relationship set and there
   41        * is no mappedBy name specified on the declaring field.
   42        * @return the mappedBy relationship if available; <code>null</code>
   43        * otherwise.
   44        */
   45       public JDORelationship getMappedBy() {
   46           if (mappedBy == null) {
   47               mappedBy = super.getMappedBy();
   48           }
   49           return mappedBy;
   50       }
   51   
   52       /**
   53        * Get the inverse JDORelationship in the case of a two-way relationship.
   54        * @return the inverse relationship
   55        */
   56       public JDORelationship getInverseRelationship() {
   57           if (inverse == null) {
   58               inverse = super.getInverseRelationship();
   59           }
   60           return inverse;
   61       }    
   62   
   63       /**
   64        * Determines whether the keys of the map should be stored if possible as 
   65        * part of the instance instead of as their own instances in the datastore.
   66        * @return <code>true</code> if the keys are stored as part of this instance;
   67        * <code>false</code> otherwise
   68        */
   69       public boolean isEmbeddedKey() {
   70           if (embeddedKey == null) {
   71               embeddedKey =
   72                   super.isEmbeddedKey() ? Boolean.TRUE : Boolean.FALSE;
   73           }
   74           return embeddedKey.booleanValue();
   75       }
   76       
   77       /**
   78        * Get the type representation of the keys for this JDOMap.
   79        * @return the type of the keys of this JDOMap  
   80        */
   81       public JavaType getKeyType() {
   82           if (keyType == null) {
   83               keyType = super.getKeyType();
   84           }
   85           return keyType;
   86       }
   87   
   88       /**
   89        * Determines whether the values of the map should be stored if possible as 
   90        * part of the instance instead of as their own instances in the datastore.
   91        * @return <code>true</code> if the values are stored as part of this 
   92        * instance; <code>false</code> otherwise
   93        */
   94       public boolean isEmbeddedValue() {
   95           if (embeddedValue == null) {
   96               embeddedValue = 
   97                   super.isEmbeddedValue() ? Boolean.TRUE : Boolean.FALSE;
   98           }
   99           return embeddedValue.booleanValue();
  100       }
  101       
  102       /**
  103        * Get the type representation of the values for this JDOMap.
  104        * @return the type of the values of this JDOMap  
  105        */
  106       public JavaType getValueType() {
  107           if (valueType == null) {
  108               valueType = super.getValueType();
  109           }
  110           return valueType;
  111       }
  112   
  113   }

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