Author: julien(a)jboss.com
Date: 2007-12-21 16:57:12 -0500 (Fri, 21 Dec 2007)
New Revision: 9381
Removed:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRelationship.java
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectManyToOne.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectOneToMany.java
Log:
simplify a bit useless complexity
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectManyToOne.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectManyToOne.java 2007-12-21
21:36:43 UTC (rev 9380)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectManyToOne.java 2007-12-21
21:57:12 UTC (rev 9381)
@@ -28,23 +28,37 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-final class UIObjectManyToOne extends UIObjectRelationship<UIContainerObject>
+final class UIObjectManyToOne
{
/** . */
private final UIObjectContext owner;
+ /** . */
+ private boolean loaded;
+
+ /** . */
+ private UIContainerObject related;
+
UIObjectManyToOne(UIObjectContext owner)
{
this.owner = owner;
}
- protected UIContainerObject doLoad()
+ UIContainerObject get()
{
- return owner.container.getParent(owner.structuralObject);
+ if (!loaded)
+ {
+ related = owner.container.getParent(owner.structuralObject);
+ }
+
+ //
+ return related;
}
- protected void doEvict(UIContainerObject abstractUIObject)
+ void clear()
{
+ related = null;
+ loaded = false;
}
}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectOneToMany.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectOneToMany.java 2007-12-21
21:36:43 UTC (rev 9380)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectOneToMany.java 2007-12-21
21:57:12 UTC (rev 9381)
@@ -29,7 +29,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-final class UIObjectOneToMany extends
UIObjectRelationship<List<UIContainerObject>>
+final class UIObjectOneToMany
{
/** . */
@@ -39,22 +39,23 @@
private final UIObjectContext owner;
/** . */
- private List<UIContainerObject> content;
+ private List<UIContainerObject> relateds;
UIObjectOneToMany(UIObjectContext object)
{
this.owner = object;
this.list = new ProxyList();
+ this.relateds = null;
}
- protected List<UIContainerObject> doLoad()
+ List<UIContainerObject> get()
{
return list;
}
- protected void doEvict(List<UIContainerObject> abstractUIObjects)
+ void clear()
{
- content = null;
+ relateds = null;
}
private class ProxyList extends AbstractList<UIContainerObject>
@@ -67,13 +68,13 @@
}
// Load the entire relationship
- if (content == null)
+ if (relateds == null)
{
- content = owner.container.getChildren(owner.structuralObject);
+ relateds = owner.container.getChildren(owner.structuralObject);
}
//
- return content.get(i);
+ return relateds.get(i);
}
public int size()
@@ -82,11 +83,11 @@
{
throw new IllegalStateException("Relationship not valid");
}
- if (content == null)
+ if (relateds == null)
{
- content = owner.container.getChildren(owner.structuralObject);
+ relateds = owner.container.getChildren(owner.structuralObject);
}
- return content.size();
+ return relateds.size();
}
}
}
Deleted:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRelationship.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRelationship.java 2007-12-21
21:36:43 UTC (rev 9380)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/container/UIObjectRelationship.java 2007-12-21
21:57:12 UTC (rev 9381)
@@ -1,79 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.presentation.impl.model.container;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 630 $
- */
-abstract class UIObjectRelationship<T>
-{
-
- /** . */
- private static final int NOT_LOADED = 0;
-
- /** . */
- private static final int LOADED = 1;
-
- /** . */
- private int status;
-
- /** . */
- private T t;
-
- public void clear()
- {
- if (status == LOADED)
- {
- T tmp = t;
-
- //
- t = null;
- status = NOT_LOADED;
-
- //
- doEvict(tmp);
- }
- }
-
- public T get()
- {
- if (status == NOT_LOADED)
- {
- t = doLoad();
- status = LOADED;
- }
-
- //
- return t;
- }
-
- protected final int getStatus()
- {
- return status;
- }
-
- protected abstract T doLoad();
-
- protected abstract void doEvict(T t);
-}