Coverage Report - org.apache.maven.plugin.ear.SecurityRole
 
Classes in this File Line Coverage Branch Coverage Complexity
SecurityRole
0%
0/31
0%
0/10
1.75
 
 1  
 package org.apache.maven.plugin.ear;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *  http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.codehaus.plexus.util.xml.XMLWriter;
 23  
 
 24  
 /**
 25  
  * The representation of a security-role entry within an
 26  
  * application.xml file.
 27  
  *
 28  
  * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
 29  
  * @version $Id: SecurityRole.java 728546 2008-12-21 22:56:51Z bentmann $
 30  
  */
 31  
 class SecurityRole
 32  
 {
 33  
 
 34  
     protected static final String SECURITY_ROLE = "security-role";
 35  
 
 36  
     protected static final String ID_ATTRIBUTE = "id";
 37  
 
 38  
     protected static final String DESCRIPTION = "description";
 39  
 
 40  
     protected static final String ROLE_NAME = "role-name";
 41  
 
 42  
     private final String roleName;
 43  
 
 44  
     private final String roleNameId;
 45  
 
 46  
     private final String roleId;
 47  
 
 48  
     private final String description;
 49  
 
 50  
     private final String descriptionId;
 51  
 
 52  
     public SecurityRole( String roleName, String roleNameId, String roleId, String description, String descriptionId )
 53  0
     {
 54  0
         if ( roleName == null )
 55  
         {
 56  0
             throw new NullPointerException( "role-name in security-role element could not be null." );
 57  
         }
 58  0
         this.roleName = roleName;
 59  0
         this.roleNameId = roleNameId;
 60  0
         this.roleId = roleId;
 61  0
         this.description = description;
 62  0
         this.descriptionId = descriptionId;
 63  0
     }
 64  
 
 65  
     public String getRoleName()
 66  
     {
 67  0
         return roleName;
 68  
     }
 69  
 
 70  
     public String getRoleNameId()
 71  
     {
 72  0
         return roleNameId;
 73  
     }
 74  
 
 75  
     public String getRoleId()
 76  
     {
 77  0
         return roleId;
 78  
     }
 79  
 
 80  
     public String getDescription()
 81  
     {
 82  0
         return description;
 83  
     }
 84  
 
 85  
     public String getDescriptionId()
 86  
     {
 87  0
         return descriptionId;
 88  
     }
 89  
 
 90  
     /**
 91  
      * Appends the <tt>XML</tt> representation of this security role.
 92  
      *
 93  
      * @param writer the writer to use
 94  
      */
 95  
     public void appendSecurityRole( XMLWriter writer )
 96  
     {
 97  0
         writer.startElement( SECURITY_ROLE );
 98  
 
 99  
         // role id
 100  0
         if ( getRoleId() != null )
 101  
         {
 102  0
             writer.addAttribute( ID_ATTRIBUTE, getRoleId() );
 103  
         }
 104  
 
 105  
         // description
 106  0
         if ( getDescription() != null )
 107  
         {
 108  0
             writer.startElement( DESCRIPTION );
 109  0
             if ( getDescriptionId() != null )
 110  
             {
 111  0
                 writer.addAttribute( ID_ATTRIBUTE, getDescriptionId() );
 112  
             }
 113  0
             writer.writeText( getDescription() );
 114  0
             writer.endElement();
 115  
 
 116  
         }
 117  
 
 118  
         // role name
 119  0
         writer.startElement( ROLE_NAME );
 120  0
         if ( getRoleNameId() != null )
 121  
         {
 122  0
             writer.addAttribute( ID_ATTRIBUTE, getRoleNameId() );
 123  
         }
 124  0
         writer.writeText( getRoleName() );
 125  0
         writer.endElement();
 126  
 
 127  
         // end of security-role
 128  0
         writer.endElement();
 129  0
     }
 130  
 
 131  
     public String toString()
 132  
     {
 133  0
         return "Security role " + getRoleName();
 134  
     }
 135  
 
 136  
 
 137  
 }