directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1691648 - in /directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers: LimitWrapper.java OrderedTimeLimitWrapper.java TimeLimitWrapper.java
Date Fri, 17 Jul 2015 21:28:07 GMT
Author: elecharny
Date: Fri Jul 17 21:28:07 2015
New Revision: 1691648

URL: http://svn.apache.org/r1691648
Log:
o Added the isValid() method in the LimitWrapper interface
o The TimeLimitWrapper constructor is now protected
o Added the OrderedTimeLimitWrapper

Added:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java
Modified:
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitWrapper.java
    directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitWrapper.java

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitWrapper.java?rev=1691648&r1=1691647&r2=1691648&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/LimitWrapper.java
Fri Jul 17 21:28:07 2015
@@ -82,4 +82,11 @@ public interface LimitWrapper extends Co
      * @return The Limit's type
      */
     String getType();
+    
+    
+    /**
+     * Tells if the LimitWrapper instance is valid
+     * @return True if this is a valid instance
+     */
+    boolean isValid();
 }

Added: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java?rev=1691648&view=auto
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java
(added)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/OrderedTimeLimitWrapper.java
Fri Jul 17 21:28:07 2015
@@ -0,0 +1,186 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.openldap.config.editor.wrappers;
+
+import org.apache.directory.api.util.Strings;
+import org.apache.directory.studio.common.ui.widgets.OrderedElement;
+
+/**
+ * This class wraps the TimeLimit parameter :
+ * <pre>
+ * time      ::= 'time' timeLimit time-e
+ * time-e    ::= ' time' timeLimit time-e | e
+ * timeLimit ::= '.soft=' limit | '.hard=' hardLimit | '=' limit
+ * limit     ::= 'unlimited' | 'none' | INT
+ * hardLimit ::= 'soft' | limit
+ * </pre>
+ * 
+ * Note : each of the limit is an Integer, so that we can have two states :
+ * <ul>
+ * <li>not existent</li>
+ * <li>has a value</li>
+ * </ul>
+ * A -1 value means unlimited. Any other value is accepted, if > 0.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class OrderedTimeLimitWrapper extends TimeLimitWrapper implements OrderedElement
+{
+    /** The prefix, used to order the values */
+    private int prefix;
+
+    /**
+     * Create a TimeLimitWrapper instance
+     * 
+     * @param globalLimit The global limit
+     * @param hardLimit The hard limit
+     * @param softLimit The soft limit
+     */
+    public OrderedTimeLimitWrapper( Integer globalLimit, Integer hardLimit, Integer softLimit
)
+    {
+        super( globalLimit, hardLimit, softLimit );
+    }
+    
+    
+    /**
+     * Create a TimeLimitWrapper instance from a String. 
+     * 
+     * @param timeLimitStr The String that contain the value
+     */
+    public OrderedTimeLimitWrapper( String timeLimitStr )
+    {
+        super( timeLimitStr );
+    }
+
+
+    /**
+     * Sets a new prefix
+     * 
+     * @param prefix the prefix to set
+     */
+    public void setPrefix( int prefix )
+    {
+        this.prefix = prefix;
+    }
+
+    
+    /**
+     * @return the prefix
+     */
+    public int getPrefix()
+    {
+        return prefix;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void decrementPrefix()
+    {
+        prefix--;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void incrementPrefix()
+    {
+        prefix++;
+    }
+
+
+    /**
+     * @see Comparable#compareTo()
+     */
+    public int compareTo( OrderedTimeLimitWrapper that )
+    {
+        if ( that == null )
+        {
+            return 1;
+        }
+        
+        // Check the prefix
+        if ( prefix < that.prefix )
+        {
+            return -1;
+        }
+        else if ( prefix > that.prefix )
+        {
+            return 1;
+        }
+        
+        return super.compareTo( that );
+    }
+
+    
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        int h = 37;
+        
+        h += h*17 + prefix;
+        
+        h += h*17 + super.hashCode();
+        
+        return h;
+    }
+
+    
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object that )
+    {
+        // Quick test
+        if ( this == that )
+        {
+            return true;
+        }
+        
+        if ( that instanceof OrderedTimeLimitWrapper )
+        {
+            OrderedTimeLimitWrapper thatInstance = (OrderedTimeLimitWrapper)that;
+            
+            if ( prefix != thatInstance.prefix )
+            {
+                return false;
+            }
+
+            return super.equals( that );
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return '{' + Integer.toString( prefix ) + '}' + super.toString();
+    }
+}

Modified: directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitWrapper.java?rev=1691648&r1=1691647&r2=1691648&view=diff
==============================================================================
--- directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitWrapper.java
(original)
+++ directory/studio/trunk/plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/wrappers/TimeLimitWrapper.java
Fri Jul 17 21:28:07 2015
@@ -45,7 +45,7 @@ public class TimeLimitWrapper extends Ab
     /**
      * Create a TimeLimitWrapper instance
      */
-    private TimeLimitWrapper()
+    protected TimeLimitWrapper()
     {
         super();
     }



Mime
View raw message