001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.om.page.impl;
018:
019: import java.util.List;
020:
021: import org.apache.jetspeed.om.page.SecurityConstraintsDef;
022: import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
023:
024: /**
025: * SecurityConstraintsDefImpl
026: *
027: * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
028: * @version $Id$
029: */
030: public class SecurityConstraintsDefImpl implements
031: SecurityConstraintsDef {
032: private int id;
033: private String name;
034: private List constraintDefs = DatabasePageManagerUtils.createList();
035:
036: private SecurityConstraintDefList securityConstraintDefs;
037:
038: /**
039: * accessConstraintDefs
040: *
041: * Access mutable persistent collection member for List wrappers.
042: *
043: * @return persistent collection
044: */
045: List accessConstraintDefs() {
046: // create initial collection if necessary
047: if (constraintDefs == null) {
048: constraintDefs = DatabasePageManagerUtils.createList();
049: }
050: return constraintDefs;
051: }
052:
053: /* (non-Javadoc)
054: * @see org.apache.jetspeed.om.page.SecurityConstraintsDef#getName()
055: */
056: public String getName() {
057: return name;
058: }
059:
060: /* (non-Javadoc)
061: * @see org.apache.jetspeed.om.page.SecurityConstraintsDef#setName(java.lang.String)
062: */
063: public void setName(String name) {
064: this .name = name;
065: }
066:
067: /* (non-Javadoc)
068: * @see org.apache.jetspeed.om.page.SecurityConstraintsDef#getSecurityConstraints()
069: */
070: public List getSecurityConstraints() {
071: // return mutable constraint def list
072: // by using list wrapper to manage apply order
073: if (securityConstraintDefs == null) {
074: securityConstraintDefs = new SecurityConstraintDefList(this );
075: }
076: return securityConstraintDefs;
077: }
078:
079: /* (non-Javadoc)
080: * @see org.apache.jetspeed.om.page.SecurityConstraintsDef#setSecurityConstraints(java.util.List)
081: */
082: public void setSecurityConstraints(List constraints) {
083: // set constraint defs by replacing existing
084: // entries with new elements if new collection
085: // is specified
086: List securityConstraintDefs = getSecurityConstraints();
087: if (constraints != securityConstraintDefs) {
088: // replace all constraints
089: securityConstraintDefs.clear();
090: if (constraints != null) {
091: securityConstraintDefs.addAll(constraints);
092: }
093: }
094: }
095:
096: /* (non-Javadoc)
097: * @see java.lang.Object#equals(java.lang.Object)
098: */
099: public boolean equals(Object o) {
100: if (o instanceof SecurityConstraintsDefImpl) {
101: if (name != null) {
102: return name.equals(((SecurityConstraintsDefImpl) o)
103: .getName());
104: }
105: return (((SecurityConstraintsDefImpl) o).getName() == null);
106: }
107: return false;
108: }
109:
110: /* (non-Javadoc)
111: * @see java.lang.Object#hashCode()
112: */
113: public int hashCode() {
114: if (name != null) {
115: return name.hashCode();
116: }
117: return 0;
118: }
119: }
|