Coverage Report - org.argouml.uml.util.namespace.Namespace
 
Classes in this File Line Coverage Branch Coverage Complexity
Namespace
N/A
N/A
1
 
 1  
 /* $Id: Namespace.java 17892 2010-01-12 21:21:35Z 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  
  *    mvw
 11  
  *****************************************************************************
 12  
  *
 13  
  * Some portions of this file was previously release using the BSD License:
 14  
  */
 15  
 
 16  
 // Copyright (c) 2003-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.uml.util.namespace;
 40  
 
 41  
 import java.util.Iterator;
 42  
 
 43  
 /**
 44  
  * The Namespace interface provides methods and constants which any class
 45  
  * dealing with namespaces needs to implement.
 46  
  *
 47  
  * @author mkl
 48  
  *
 49  
  */
 50  
 public interface Namespace {
 51  
 
 52  
     /**
 53  
      * the scope token for java.
 54  
      */
 55  
     public static final String JAVA_NS_TOKEN = ".";
 56  
 
 57  
     /**
 58  
      * the scope token for uml.
 59  
      */
 60  
     public static final String UML_NS_TOKEN = "::";
 61  
 
 62  
     /**
 63  
      * the scope token for c++.
 64  
      */
 65  
     public static final String CPP_NS_TOKEN = "::";
 66  
 
 67  
     /**
 68  
      * returns the namespace which is common to both namespaces, e.g.
 69  
      * <code>org.argouml.model</code>
 70  
      * and <code>org.argouml.util</code> have <code>org.argouml</code> in
 71  
      * common.
 72  
      *
 73  
      * @param namespace
 74  
      *            a namespace
 75  
      * @return the common or empty namespace
 76  
      */
 77  
     Namespace getCommonNamespace(Namespace namespace);
 78  
 
 79  
     /**
 80  
      * returns the base of a namespace, e.g. the base of
 81  
      * <code>org.argouml.util</code>
 82  
      * is <code>org.argouml</code>.
 83  
      *
 84  
      * @return base namespace
 85  
      */
 86  
     Namespace getBaseNamespace();
 87  
 
 88  
     /**
 89  
      * add another element to a namespace.
 90  
      *
 91  
      * @param element the element to add
 92  
      */
 93  
     void pushNamespaceElement(NamespaceElement element);
 94  
 
 95  
     /**
 96  
      * reduces the innermost namespace element,
 97  
      * e.g. <code>org.argouml.model</code>
 98  
      * will return <code>model</code>, and change the namespace
 99  
      * to <code>org.argouml</code>.
 100  
      *
 101  
      * @return the popped element.
 102  
      */
 103  
     NamespaceElement popNamespaceElement();
 104  
 
 105  
     /**
 106  
      * return the innermost namespace element without removing it.
 107  
      *
 108  
      * @return the innermost namespace element
 109  
      */
 110  
     NamespaceElement peekNamespaceElement();
 111  
 
 112  
     /**
 113  
      * namespaces usually have a scope operator when used in representational
 114  
      * form. see also the predifined constants.
 115  
      *
 116  
      * @param token
 117  
      *            the token to use from now on.
 118  
      */
 119  
     void setDefaultScopeToken(String token);
 120  
 
 121  
     /**
 122  
      * return an iterator to the namespace elements.
 123  
      *
 124  
      * @return an iterator of NamespaceElements.
 125  
      */
 126  
     Iterator iterator();
 127  
 
 128  
     /**
 129  
      * check if the namespace is empty.
 130  
      *
 131  
      * @return true if empty
 132  
      */
 133  
     boolean isEmpty();
 134  
 
 135  
     /**
 136  
      * return a string representation of the namespace with the given token.
 137  
      * The existence of the method implies that classes also must implement
 138  
      * toString() in a reasonable manner using the default token.
 139  
      *
 140  
      * @param token the token to be converted
 141  
      * @return a string representation of the namespace
 142  
      */
 143  
     String toString(String token);
 144  
 }