Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.codehaus.mojo.rpm;
  
  /*
   * 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.
  */
 
 import java.util.List;

A description of a file or directory to be installed. It includes the properties to be assigned and the location(s) where the file(s) can be found for packaging.

Version:
$Id: Mapping.java 5261 2007-10-07 14:03:39Z boba $
 
 public class Mapping
 {
     
     // // //  Properties
     
    
Destination directory name.
 
     private String directory;
    
    
true if the files are configuration.
 
     private boolean configuration;
    
    
true if the files are documentation.
 
     private boolean documentation;
    
    
File mode (octal string) to assign to files when installed.
 
     private String filemode;
    
    
User name for files when installed.
 
     private String username;
    
    
Group name for files when installed.
 
     private String groupname;
    
    
Mapping information for source directories.
 
     private List sources;
    
    
Mapping information for artifacts.
 
     private ArtifactMap artifact;
    
    
Mapping information for dependencies.
 
     private Dependency dependency;
     
     // // //  Bean methods
     
    
Retrieve the destination during package installation.

Returns:
The destination during package installation.
 
     public String getDirectory()
     {
         return ;
     }
    
    
Set the destination during package installation.

Parameters:
dir The new destination during package installation.
 
     public void setDirectoryString dir )
     {
          = dir;
     }
    
    
Retrieve the configuration status. This value is true if the file(s) in this mapping are configuration files.

Returns:
The configuration status.
 
     public boolean isConfiguration()
     {
         return ;
     }
    
    
Set the configuration status. This value is true if the file(s) in this mapping are configuration files.

Parameters:
isCfg The new configuration status.
 
     public void setConfigurationboolean isCfg )
     {
          = isCfg;
    }
    
    
Retrieve the documentation status. This value is true if the file(s) in this mapping are documentation files.

Returns:
The documentation status.
    public boolean isDocumentation()
    {
        return ;
    }
    
    
Set the documentation status. This value is true if the file(s) in this mapping are documentation files.

Parameters:
isDoc The new documentation status.
    public void setDocumentationboolean isDoc )
    {
         = isDoc;
    }
    
    
Retrieve the UNIX file permissions. This is a three-digit octal number which specifies the permissions to be applied to each file in the mapping when it is installed.

Returns:
The UNIX file permissions.
    public String getFilemode()
    {
        return ;
    }
    
    
Set the UNIX file permissions. This is a three-digit octal number which specifies the permissions to be applied to each file in the mapping when it is installed.

Parameters:
fmode The new UNIX file permissions.
    public void setFilemodeString fmode )
    {
         = fmode;
    }
    
    
Retrieve the UNIX user name to own the installed files. Note that this must be a name, not a numeric user ID.

Returns:
The UNIX user name to own the installed files.
    public String getUsername()
    {
        return ;
    }
    
    
Set the UNIX user name to own the installed files. Note that this must be a name, not a numeric user ID.

Parameters:
uname The new UNIX user name to own the installed files.
    public void setUsernameString uname )
    {
         = uname;
    }
    
    
Retrieve the UNIX group name to own the installed files. Note that this must be a name, not a numeric group ID.

Returns:
The UNIX group name to own the installed files.
    public String getGroupname()
    {
        return ;
    }
    
    
Set the UNIX group name to own the installed files. Note that this must be a name, not a numeric group ID.

Parameters:
grpname The new UNIX group name to own the installed files.
    public void setGroupnameString grpname )
    {
         = grpname;
    }
    
    
Retrieve the list of source file specifications.

Returns:
The list of source file specifications.
    public List getSources()
    {
        return ;
    }
    
    
Set the list of source file specifications.

Parameters:
srclist The new list of source file specifications.
    public void setSourcesList srclist )
    {
         = srclist;
    }
    
    
Retrieve the artifact specification.

Returns:
The artifact specification.
    public ArtifactMap getArtifact()
    {
        return ;
    }
    
    
Set the artifact specification.

Parameters:
am The new artifact specification.
    public void setArtifactArtifactMap am )
    {
         = am;
    }
    
    
Retrieve the dependency specification.

Returns:
The dependency specification.
    public Dependency getDependency()
    {
        return ;
    }
    
    
Set the dependency specification.

Parameters:
am The new dependency specification.
    public void setDependencyDependency am )
    {
         = am;
    }
    
    // // //  Public methods
    
    
Assemble the RPM SPEC file attributes for a mapping.

Returns:
The attribute string for the SPEC file.
    public String getAttrString()
    {
        StringBuffer sb = new StringBuffer();
        
        if (  )
        {
            sb.append"%config " );
        }
        
        if (  )
        {
            sb.append"%doc " );
        }
        
        if ( ( (  == null ) || ( .size() == 0 ) )
                && (  == null ) && (  == null ) )
        {
            sb.append"%dir " );
        }
        
        if (  != null )
        {
            sb.append"%attr(" +  + "," );
        }
        else
        {
            sb.append"%attr(-," );
        }
        
        if (  != null )
        {
            sb.append + "," );
        }
        else
        {
            sb.append"-," );
        }
        
        if (  != null )
        {
            sb.append + ")" );
        }
        else
        {
            sb.append"-)" );
        }
        
        return sb.toString();
    }
    
    
Return the destination directory name.

Returns:
The name of the destination directory.
    public String getDestination()
    {
        if (  == null )
        {
            return "nowhere";
        }
        else
        {
            return ;
        }
    }
    
    
Return directory-only status.

Returns:
true if no sources were specified in the mapping
    public boolean isDirOnly()
    {
        if ( (  != null ) && ( !.isEmpty() ) )
        {
            return false;
        }
        
        if (  != null )
        {
            return false;
        }
        
        if (  != null )
        {
            return false;
        }
        
        return true;
    }
    
    
    public String toString()
    {
        boolean sourceShown = false;
        StringBuffer sb = new StringBuffer();
        
        sb.append"[\"" + getDestination() + "\" " );
        sb.append"{" + getAttrString() + "}" );
        
        if ( isDirOnly() )
        {
            sb.append" (dir only)]" );
        }
        else
        {
            sb.append" from " );
            if (  != null )
            {
                sb.append.toString() );
                sourceShown = true;
            }
            if (  != null )
            {
                if ( sourceShown )
                {
                    sb.append", " );
                }
                sb.append.toString() );
                sourceShown = true;
            }
            if (  != null )
            {
                if ( sourceShown )
                {
                    sb.append", " );
                }
                sb.append.toString() );
                sourceShown = true;
            }
            sb.append"]" );
        }
        
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X