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.JDOArrayImplDynamic;
   23   
   24   /**
   25    * An instance of this class represents the JDO relationship metadata 
   26    * of a array relationship field. This caching implementation
   27    * caches any calulated value to avoid re-calculating it if it is
   28    * requested again. 
   29    *
   30    * @author Michael Bouschen
   31    * @since 1.1
   32    * @version 2.0
   33    */
   34   public class JDOArrayImplCaching extends JDOArrayImplDynamic {
   35       
   36       /** Type of the array element. */
   37       private transient JavaType elementType;
   38       
   39       /** 
   40        * Get the mappedBy relationship. If there is no mappedBy relationship
   41        * set, the method checks the mappedBy name as specified in the declaring
   42        * field and resolves the relationship. The method returns
   43        * <code>null</code> if there is no mappedBy relationship set and there
   44        * is no mappedBy name specified on the declaring field.
   45        * @return the mappedBy relationship if available; <code>null</code>
   46        * otherwise.
   47        */
   48       public JDORelationship getMappedBy() {
   49           if (mappedBy == null) {
   50               mappedBy = super.getMappedBy();
   51           }
   52           return mappedBy;
   53       }
   54   
   55       /**
   56        * Get the inverse JDORelationship in the case of a two-way relationship.
   57        * @return the inverse relationship
   58        */
   59       public JDORelationship getInverseRelationship() {
   60           if (inverse == null) {
   61               inverse = super.getInverseRelationship();
   62           }
   63           return inverse;
   64       }
   65   
   66       /**
   67        * Determines whether the values of the elements should be stored 
   68        * if possible as part of the instance instead of as their own instances 
   69        * in the datastore.
   70        * @return <code>true</code> if the elements should be stored as part of 
   71        * the instance; <code>false</code> otherwise
   72        */
   73       public boolean isEmbeddedElement() {
   74           if (embeddedElement == null) {
   75               embeddedElement = 
   76                   super.isEmbeddedElement() ? Boolean.TRUE : Boolean.FALSE;
   77           }
   78           return embeddedElement.booleanValue();
   79       }
   80       
   81       /** 
   82        * Get the type representation of the array component type. 
   83        * @return the array component type
   84        */
   85       public JavaType getElementType() {
   86           if (elementType == null) {
   87               elementType = super.getElementType();
   88           }
   89           return elementType;
   90       }
   91   
   92   }
   93   

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