Coverage Report - org.argouml.persistence.XMLElement
 
Classes in this File Line Coverage Branch Coverage Complexity
XMLElement
0%
0/22
N/A
1
 
 1  
 /* $Id: XMLElement.java 17832 2010-01-12 19:02:29Z linus $
 2  
  *****************************************************************************
 3  
  * Copyright (c) 2009 Contributors - see below
 4  
  * All rights reserved. This program and the accompanying materials
 5  
  * are made available under the terms of the Eclipse Public License v1.0
 6  
  * which accompanies this distribution, and is available at
 7  
  * http://www.eclipse.org/legal/epl-v10.html
 8  
  *
 9  
  * Contributors:
 10  
  *    bobtarling
 11  
  *****************************************************************************
 12  
  *
 13  
  * Some portions of this file was previously release using the BSD License:
 14  
  */
 15  
 
 16  
 // Copyright (c) 1996-2006 The Regents of the University of California. All
 17  
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 18  
 // software and its documentation without fee, and without a written
 19  
 // agreement is hereby granted, provided that the above copyright notice
 20  
 // and this paragraph appear in all copies.  This software program and
 21  
 // documentation are copyrighted by The Regents of the University of
 22  
 // California. The software program and documentation are supplied "AS
 23  
 // IS", without any accompanying services from The Regents. The Regents
 24  
 // does not warrant that the operation of the program will be
 25  
 // uninterrupted or error-free. The end-user understands that the program
 26  
 // was developed for research purposes and is advised not to rely
 27  
 // exclusively on the program for any reason.  IN NO EVENT SHALL THE
 28  
 // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
 29  
 // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
 30  
 // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
 31  
 // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
 32  
 // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
 33  
 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 34  
 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
 35  
 // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
 36  
 // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
 37  
 // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 38  
 
 39  
 package org.argouml.persistence;
 40  
 
 41  
 import org.xml.sax.Attributes;
 42  
 import org.xml.sax.helpers.AttributesImpl;
 43  
 
 44  
 /**
 45  
  * @author Jim Holt
 46  
  */
 47  
 class XMLElement {
 48  
 
 49  
     ////////////////////////////////////////////////////////////////
 50  
     // instance variables
 51  
 
 52  0
     private String        name       = null;
 53  0
     private StringBuffer  text       = new StringBuffer(100);
 54  0
     private Attributes    attributes = null;
 55  
 
 56  
     /**
 57  
      * Constructor.
 58  
      *
 59  
      * @param n The name of the element.
 60  
      * @param a The attributes.
 61  
      */
 62  0
     public XMLElement(String n, Attributes a) {
 63  0
         name = n;
 64  0
         attributes = new AttributesImpl(a);
 65  0
     }
 66  
 
 67  
     ////////////////////////////////////////////////////////////////
 68  
     // accessors
 69  
 
 70  
     /**
 71  
      * @return the name of this element
 72  
      */
 73  0
     public String getName()            { return name; }
 74  
     /**
 75  
      * @param n the name of this element
 76  
      */
 77  0
     public void   setName(String n) { name = n; }
 78  
 
 79  
     /**
 80  
      * @param t the text to be appended
 81  
      */
 82  0
     public void   addText(String t) { text = text.append(t); }
 83  
 
 84  
     /**
 85  
      * Append text to the end of the element.
 86  
      * @param c character array containing the text to be appended
 87  
      * @param offset starting offset of text
 88  
      * @param len length of text to append
 89  
      */
 90  
     public void addText(char[] c, int offset, int len) {
 91  0
         text = text.append(c, offset, len);
 92  0
     }
 93  
     
 94  
     /**
 95  
      * @param t the new text
 96  
      */
 97  0
     public void   setText(String t) { text = new StringBuffer(t); }
 98  
 
 99  
     /**
 100  
      * Erase the text of this element.
 101  
      */
 102  0
     public void   resetText()          { text.setLength(0); }
 103  
 
 104  
     /**
 105  
      * @return the text of this element
 106  
      */
 107  0
     public String getText()            { return text.toString(); }
 108  
 
 109  
     /**
 110  
      * Get the length of the text in the element.
 111  
      * @return the length of the text in this element
 112  
      */
 113  0
     public int length()            { return text.length(); }
 114  
 
 115  
     /**
 116  
      * Change the attributes for this element.
 117  
      *
 118  
      * @param a The new list of attributes.
 119  
      */
 120  
     public void   setAttributes(Attributes a) {
 121  0
         attributes = new AttributesImpl(a);
 122  0
     }
 123  
 
 124  
     /**
 125  
      * @param attribute the attribute name
 126  
      * @return the attribute value
 127  
      */
 128  
     public String getAttribute(String attribute) {
 129  0
         return attributes.getValue(attribute);
 130  
     }
 131  
 
 132  
     /**
 133  
      * @param i the index for the list of attributes
 134  
      * @return the attribute name for the attribute at the given index
 135  
      */
 136  
     public String getAttributeName(int i) {
 137  0
         return attributes.getLocalName(i);
 138  
     }
 139  
 
 140  
     /**
 141  
      * @param i the index for the list of attributes
 142  
      * @return the attribute value for the attribute at the given index
 143  
      */
 144  
     public String getAttributeValue(int i) {
 145  0
         return attributes.getValue(i);
 146  
     }
 147  
 
 148  
     /**
 149  
      * @return the number of attributes
 150  
      */
 151  0
     public int    getNumAttributes() { return attributes.getLength(); }
 152  
 
 153  
 } /* end class XMLElement */