Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  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.connection.core;
 
 
 import java.util.List;
 import java.util.UUID;
 
A ConnectionFolder helps to organize connections in folders.

Author(s):
Apache Directory Project
 
 public class ConnectionFolder implements Cloneable
 {
     private String id;
 
     private String name;
 
     private List<StringsubFolderIds;
 
     private List<StringconnectionIds;


    
Creates a new instance of ConnectionFolder.
 
     public ConnectionFolder()
     {
         this. = new ArrayList<String>();
         this. = new ArrayList<String>();
     }


    
Creates a new instance of ConnectionFolder.

Parameters:
name the folder name
 
     public ConnectionFolderString name )
     {
         this();
         this. = createId();
         this. = name;
     }


    
 
     public Object clone()
     {
         ConnectionFolder folder = new ConnectionFoldergetName() );
 
         // clone connections
         ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
         for ( String id :  )
         {
             Connection connection = connectionManager.getConnectionByIdid );
             if ( connection != null )
             {
                 Connection newConnection = ( Connection ) connection.clone();
                 connectionManager.addConnectionnewConnection );
                 folder.addConnectionIdnewConnection.getId() );
             }
         }
 
         // clone subfolders
         ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
             .getConnectionFolderManager();
         for ( String id :  )
         {
             ConnectionFolder subFolder = connectionFolderManager.getConnectionFolderByIdid );
             if ( subFolder != null )
             {
                 ConnectionFolder newFolder = ( ConnectionFolder ) subFolder.clone();
                 connectionFolderManager.addConnectionFoldernewFolder );
                folder.addSubFolderIdnewFolder.getId() );
            }
        }
        return folder;
    }


    
Adds the connection id to the end of the connection list.

Parameters:
connectionId the connection id
    public void addConnectionIdString connectionId )
    {
        .addconnectionId );
        ConnectionEventRegistry.fireConnectonFolderModifiedthisthis );
    }


    
Removes the connection id from the connection list.

Parameters:
connectionId the connection id
    public void removeConnectionIdString connectionId )
    {
        .removeconnectionId );
        ConnectionEventRegistry.fireConnectonFolderModifiedthisthis );
    }


    
Adds the folder id to the end of the sub-folder list.

Parameters:
folderId the folder id
    public void addSubFolderIdString folderId )
    {
        .addfolderId );
        ConnectionEventRegistry.fireConnectonFolderModifiedthisthis );
    }


    
Removes the connection folder from the sub-folder list.

Parameters:
folderId the folder id
    public void removeSubFolderIdString folderId )
    {
        .removefolderId );
        ConnectionEventRegistry.fireConnectonFolderModifiedthisthis );
    }


    
Gets the id.

Returns:
the id
    public String getId()
    {
        if (  == null )
        {
             = createId();
        }
        return ;
    }


    
Sets the id.

Parameters:
id the new id
    public void setIdString id )
    {
        this. = id;
    }


    
Gets the name.

Returns:
the name
    public String getName()
    {
        return ;
    }


    
Sets the name.

Parameters:
name the new name
    public void setNameString name )
    {
        this. = name;
        ConnectionEventRegistry.fireConnectonFolderModifiedthisthis );
    }


    
Gets the sub-folder ids.

Returns:
the sub-folder ids
    public List<StringgetSubFolderIds()
    {
        List<Stringids = new ArrayList<String>();
        for ( String id :  )
        {
            if ( ConnectionCorePlugin.getDefault().getConnectionFolderManager().getConnectionFolderByIdid ) != null )
            {
                ids.addid );
            }
        }
        return ids;
    }


    
Sets the sub-folder ids.

Parameters:
subFolderIds the new sub-folder ids
    public void setSubFolderIdsList<StringsubFolderIds )
    {
        this. = subFolderIds;
        ConnectionEventRegistry.fireConnectonFolderModifiedthisthis );
    }


    
Gets the connection ids.

Returns:
the connection ids
    public List<StringgetConnectionIds()
    {
        List<Stringids = new ArrayList<String>();
        for ( String id :  )
        {
            if ( ConnectionCorePlugin.getDefault().getConnectionManager().getConnectionByIdid ) != null )
            {
                ids.addid );
            }
        }
        return ids;
    }


    
Sets the connection ids.

Parameters:
connectionIds the new connection ids
    public void setConnectionIdsList<StringconnectionIds )
    {
        this. = connectionIds;
        ConnectionEventRegistry.fireConnectonFolderModifiedthisthis );
    }


    
Creates a unique id.

Returns:
the created id
    private String createId()
    {
        return UUID.randomUUID().toString();
    }


    
    public int hashCode()
    {
        return getId().hashCode();
    }


    
    public boolean equalsObject obj )
    {
        if ( obj instanceof ConnectionFolder )
        {
            ConnectionFolder other = ( ConnectionFolder ) obj;
            return getId().equalsother.getId() );
        }
        return false;
    }
New to GrepCode? Check out our FAQ X