Skip to content

Commit

Permalink
Major refactoring: use better naming conventions
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/cocoon/trunk/blocks@426912 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cziegeler committed Jul 30, 2006
1 parent bed9ae7 commit 70f6ea0
Show file tree
Hide file tree
Showing 144 changed files with 1,625 additions and 1,567 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void dispose() {
/**
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
super.service(manager);
public void service(ServiceManager aManager) throws ServiceException {
super.service(aManager);
this.portalService = (PortalService) this.manager.lookup(PortalService.ROLE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class CopletEventDescription extends CopletMapping {
/**
* @see org.apache.cocoon.portal.acting.helpers.Mapping#getEvent(org.apache.cocoon.portal.PortalService, java.lang.Object)
*/
public Event getEvent(PortalService service, Object data) {
return super.getEvent(service, (data == null ? this.data : data));
public Event getEvent(PortalService service, Object eventData) {
return super.getEvent(service, (eventData == null ? this.data : eventData));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.apache.cocoon.portal.acting.helpers;

import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.coplet.CopletInstanceData;
import org.apache.cocoon.portal.coplet.CopletInstance;
import org.apache.cocoon.portal.event.Event;
import org.apache.cocoon.portal.event.coplet.CopletJXPathEvent;

Expand All @@ -34,7 +34,7 @@ public class CopletMapping extends Mapping {
* @see org.apache.cocoon.portal.acting.helpers.Mapping#getEvent(org.apache.cocoon.portal.PortalService, java.lang.Object)
*/
public Event getEvent(PortalService service, Object data) {
CopletInstanceData cid = service.getProfileManager().getCopletInstanceData(this.copletId);
CopletInstance cid = service.getProfileManager().getCopletInstanceData(this.copletId);
Event e = new CopletJXPathEvent(cid, this.path, data);
return e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.apache.cocoon.portal.acting.helpers;

import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.coplet.CopletInstanceData;
import org.apache.cocoon.portal.coplet.CopletInstance;
import org.apache.cocoon.portal.event.Event;
import org.apache.cocoon.portal.event.coplet.CopletInstanceSizingEvent;
import org.apache.cocoon.portal.profile.ProfileManager;
Expand All @@ -36,10 +36,10 @@ public class FullScreenMapping extends Mapping {
*/
public Event getEvent(PortalService service, Object data) {
final ProfileManager manager = service.getProfileManager();
final CopletInstanceData cid = manager.getCopletInstanceData(this.copletId);
final CopletInstance cid = manager.getCopletInstanceData(this.copletId);
//final Layout layout = manager.getPortalLayout(null, layoutId) ;

Event e = new CopletInstanceSizingEvent(cid, CopletInstanceData.SIZE_FULLSCREEN);
Event e = new CopletInstanceSizingEvent(cid, CopletInstance.SIZE_FULLSCREEN);
return e;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class LayoutEventDescription extends LayoutMapping {
/**
* @see org.apache.cocoon.portal.acting.helpers.Mapping#getEvent(org.apache.cocoon.portal.PortalService, java.lang.Object)
*/
public Event getEvent(PortalService service, Object data) {
return super.getEvent(service, (data == null ? this.data : data));
public Event getEvent(PortalService service, Object eventData) {
return super.getEvent(service, (eventData == null ? this.data : eventData));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public abstract class AbstractModule
/**
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
public void service(ServiceManager aManager) throws ServiceException {
this.manager = aManager;
this.portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@ public class LayoutModule
*/
public Object getAttribute(String name, Configuration modeConf, Map objectModel)
throws ConfigurationException {
int pos = name.indexOf('/');
String key = name;
int pos = key.indexOf('/');
String path;
if ( pos == -1 ) {
path = null;
} else {
path = name.substring(pos + 1);
name = name.substring(0, pos);
path = key.substring(pos + 1);
key = key.substring(0, pos);
}
// is the layout key specified?
pos = name.indexOf(':');
pos = key.indexOf(':');
String layoutKey = null;
String layoutId = name;
String layoutId = key;
if ( pos != -1 ) {
layoutKey = name.substring(0, pos);
layoutId = name.substring(pos + 1);
layoutKey = key.substring(0, pos);
layoutId = key.substring(pos + 1);
}

// get the layout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void dispose() {
*/
public Object getAttribute(String name, Configuration modeConf, Map objectModel)
throws ConfigurationException {
String key = name;
// lazy init
if ( this.globalModule == null ) {
synchronized ( this ) {
Expand All @@ -67,10 +68,10 @@ public Object getAttribute(String name, Configuration modeConf, Map objectModel)

String skinName = null;
// if the attribute already contains a ':', the name is prefixed with the skin name
int pos = name.indexOf(':');
int pos = key.indexOf(':');
if ( pos != -1 ) {
skinName = name.substring(0, pos);
name = name.substring(pos+1);
skinName = key.substring(0, pos);
key = key.substring(pos+1);
} else {
// get the current skin
// the skin is stored as a parameter on the root layout
Expand Down Expand Up @@ -99,14 +100,14 @@ public Object getAttribute(String name, Configuration modeConf, Map objectModel)
}
}
if ( desc != null ) {
if ( "skin".equals(name) ) {
if ( "skin".equals(key) ) {
return skinName;
} else if ( "skin.basepath".equals(name) ) {
} else if ( "skin.basepath".equals(key) ) {
return desc.getBasePath();
} else if ( "skin.thumbnailpath".equals(name) ) {
} else if ( "skin.thumbnailpath".equals(key) ) {
return desc.getThumbnailPath();
} else if ( name.startsWith("skin.thumbnailuri.") ) {
String selectedSkinName = name.substring(name.lastIndexOf(".")+ 1, name.length());
} else if ( key.startsWith("skin.thumbnailuri.") ) {
String selectedSkinName = key.substring(key.lastIndexOf(".")+ 1, key.length());
for(Iterator it = portalService.getSkinDescriptions().iterator(); it.hasNext();) {
SkinDescription selected = (SkinDescription) it.next();
if(selected.getName().equals(selectedSkinName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@
import org.apache.commons.lang.StringUtils;

/**
* A coplet data describes an available coplet. A coplet data can be seen
* A coplet definition describes an available coplet. A coplet definition can be seen
* as a class. A user can create one or more instances of the coplet
* ({@link CopletInstanceData}s).
* ({@link CopletInstance}s).
*
* @version $Id$
*/
public class CopletData implements Serializable {
public class CopletDefinition implements Serializable {

/** The unique identifier. */
protected final String id;

protected String title;

protected CopletBaseData copletBaseData;
protected CopletType copletType;

protected Map attributes = new HashMap();
protected final Map attributes = new HashMap();

protected String allowedRoles;

Expand All @@ -53,7 +53,7 @@ public class CopletData implements Serializable {
* @param id The unique id of the object.
* @see PortalUtils#testId(String)
*/
public CopletData(String id) {
public CopletDefinition(String id) {
final String idErrorMsg = PortalUtils.testId(id);
if ( idErrorMsg != null ) {
throw new IllegalArgumentException(idErrorMsg);
Expand Down Expand Up @@ -86,19 +86,19 @@ public void setTitle(String title) {
}

/**
* Returns the copletBaseData.
* @return CopletBaseData
* Returns the type of the coplet.
* @return CopletType
*/
public CopletBaseData getCopletBaseData() {
return copletBaseData;
public CopletType getCopletType() {
return this.copletType;
}

/**
* Sets the copletBaseData.
* @param copletBaseData The copletBaseData to set
* Sets the type of the coplet.
* @param copletType The coplet type to set
*/
public void setCopletBaseData(CopletBaseData copletBaseData) {
this.copletBaseData = copletBaseData;
public void setCopletType(CopletType copletType) {
this.copletType = copletType;
}

public Object removeAttribute(String key) {
Expand Down Expand Up @@ -201,7 +201,7 @@ protected void buildRolesString(List fromList) {
* @see java.lang.Object#toString()
*/
public String toString() {
return "CopletData (" + this.hashCode() +
"), id=" + this.getId() + ", coplet-base-data=" + (this.getCopletBaseData() == null ? "null" : this.getCopletBaseData().getId());
return "CopletDefinition (" + this.hashCode() +
"), id=" + this.getId() + ", coplet-type=" + (this.getCopletType() == null ? "null" : this.getCopletType().getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @version $Id$
*/
public final class CopletDataFeatures {
public final class CopletDefinitionFeatures {

/** This is the name of the coplet data attribute containing a boolean value
* indicating if the user is allowed to resize the coplet. (default is true) */
Expand All @@ -43,10 +43,10 @@ public final class CopletDataFeatures {
* meaning the portal handles the state and renders only the title). */
public static final String ATTRIBUTE_HANDLE_SIZING = "handle-sizing";

public static Object getAttributeValue(CopletData data, String key, Object defaultValue) {
public static Object getAttributeValue(CopletDefinition data, String key, Object defaultValue) {
Object value = data.getAttribute(key);
if ( value == null ) {
value = data.getCopletBaseData().getCopletConfig(key);
value = data.getCopletType().getCopletConfig(key);
if ( value == null ) {
value = defaultValue;
}
Expand All @@ -57,40 +57,40 @@ public static Object getAttributeValue(CopletData data, String key, Object defau
/**
* Is this coplet sizable?
*/
public static boolean isSizable(CopletData data) {
public static boolean isSizable(CopletDefinition data) {
Boolean sizable = (Boolean)getAttributeValue(data, ATTRIBUTE_SIZABLE, Boolean.TRUE);
return sizable.booleanValue();
}

/**
* Is this coplet mandatory?
*/
public static boolean isMandatory(CopletData data) {
public static boolean isMandatory(CopletDefinition data) {
Boolean mandatory = (Boolean)getAttributeValue(data, ATTRIBUTE_MANDATORY, Boolean.FALSE);
return mandatory.booleanValue();
}

/**
* Does this coplet support the full screen mode?
*/
public static boolean supportsFullScreenMode(CopletData data) {
public static boolean supportsFullScreenMode(CopletDefinition data) {
Boolean supportsMode = (Boolean)getAttributeValue(data, ATTRIBUTE_FULLSCREEN, Boolean.TRUE);
return supportsMode.booleanValue();
}

/**
* Does this coplet handles sizing by itself?
*/
public static boolean handlesSizing(CopletData data) {
public static boolean handlesSizing(CopletDefinition data) {
Boolean handlesSizing = (Boolean)getAttributeValue(data, ATTRIBUTE_HANDLE_SIZING, Boolean.FALSE);
return handlesSizing.booleanValue();
}

public static void setSizable(CopletData data, boolean value) {
public static void setSizable(CopletDefinition data, boolean value) {
data.setAttribute(ATTRIBUTE_SIZABLE, BooleanUtils.toBooleanObject(value));
}

public static void setMandatory(CopletData data, boolean value) {
public static void setMandatory(CopletDefinition data, boolean value) {
data.setAttribute(ATTRIBUTE_MANDATORY, BooleanUtils.toBooleanObject(value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ public interface CopletFactory {
* Create a new coplet instance.
* This is also registered at the profile manager.
*/
CopletInstanceData newInstance(CopletData copletData)
CopletInstance newInstance(CopletDefinition copletDef)
throws PortalException;

/**
* Create a new coplet instance.
* This is also registered at the profile manager.
*/
CopletInstanceData newInstance(CopletData copletData,
String id)
CopletInstance newInstance(CopletDefinition copletDef,
String id)
throws PortalException;

/**
* Remove the coplet instance data.
* This is also unregistered at the profile manager.
*/
void remove(CopletInstanceData copletInstanceData);
void remove(CopletInstance copletInstanceData);

/**
* Create a new coplet data instance.
*/
CopletData newInstance(CopletBaseData copletBaseData, String id)
CopletDefinition newInstance(CopletType copletType, String id)
throws PortalException;
}
Loading

0 comments on commit 70f6ea0

Please sign in to comment.