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.impl.model.jdo.JDOCollectionImplDynamic;
   21   import org.apache.jdo.model.jdo.JDORelationship;
   22   import org.apache.jdo.model.java.JavaType;
   23   
   24   /**
   25    * An instance of this class represents the JDO relationship metadata 
   26    * of a collection 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 JDOCollectionImplCaching extends JDOCollectionImplDynamic {
   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 values of the elements should be stored if 
   65        * possible as part of the instance instead of as their own instances 
   66        * in the datastore.
   67        * @return <code>true</code> if the elements should be stored as part of 
   68        * the instance; <code>false</code> otherwise
   69        */
   70       public boolean isEmbeddedElement() {
   71           if (embeddedElement == null) {
   72               embeddedElement = 
   73                   super.isEmbeddedElement() ? Boolean.TRUE : Boolean.FALSE;
   74           }
   75           return (embeddedElement == null) ? false : 
   76               embeddedElement.booleanValue();
   77       }
   78       
   79       /** 
   80        * Get the type representation of the collection elements. 
   81        * @return the element type
   82        */
   83       public JavaType getElementType()
   84       {
   85           if (elementType == null) {
   86               elementType = super.getElementType();
   87           }
   88           return elementType;
   89       }
   90   
   91   }

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