PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Java|javax|naming|CompoundName.java =

page 6 of 7



      * @param	posn	The index at which to add the new component.
      *			Must be in the range [0,size()].
      * @exception ArrayIndexOutOfBoundsException
      *		If posn is outside the specified range.
      * @return The updated CompoundName, not a new one. Cannot be null.
      * @exception InvalidNameException If adding comp at the specified position
      *				would violate the compound name's syntax.
      */
    public Name add(int posn, String comp) throws InvalidNameException{
	impl.add(posn, comp);
	return this;
    }

    /**
      * Deletes a component from this compound name.
      * The component of this compound name at position 'posn' is removed,
      * and components at indices greater than 'posn'
      * are shifted down (towards index 0) by one.
      *
      * @param	posn	The index of the component to delete.
      *			Must be in the range [0,size()).
      * @return The component removed (a String).
      * @exception ArrayIndexOutOfBoundsException
      *		If posn is outside the specified range (includes case where
      *		compound name is empty).
      * @exception InvalidNameException If deleting the component
      *				would violate the compound name's syntax.
      */
    public Object remove(int posn) throws InvalidNameException {
	return impl.remove(posn);
    }

    /**
     * Overridden to avoid implementation dependency.
     * @serialData The syntax <tt>Properties</tt>, followed by
     * the number of components (an <tt>int</tt>), and the individual
     * components (each a <tt>String</tt>).
     */
    private void writeObject(java.io.ObjectOutputStream s)
	    throws java.io.IOException {
	s.writeObject(mySyntax);
	s.writeInt(size());
	Enumeration comps = getAll();
	while (comps.hasMoreElements()) {
	    s.writeObject(comps.nextElement());
	}
    }

    /**
     * Overridden to avoid implementation dependency.
     */
    private void readObject(java.io.ObjectInputStream s)
	    throws java.io.IOException, ClassNotFoundException {
	mySyntax = (Properties)s.readObject();
	impl = new NameImpl(mySyntax);
	int n = s.readInt();	// number of components
	try {
	    while (--n >= 0) {
		add((String)s.readObject());
	    }
	} catch (InvalidNameException e) {
	    throw (new java.io.StreamCorruptedException("Invalid name"));
	}
    }

    /**
     * Use serialVersionUID from JNDI 1.1.1 for interoperability
     */
    private static final long serialVersionUID = 3513100557083972036L;

/*
//   For testing

    public static void main(String[] args) {
	Properties dotSyntax = new Properties();
	dotSyntax.put("jndi.syntax.direction", "right_to_left");
	dotSyntax.put("jndi.syntax.separator", ".");
	dotSyntax.put("jndi.syntax.ignorecase", "true");
	dotSyntax.put("jndi.syntax.escape", "\\");
//	dotSyntax.put("jndi.syntax.beginquote", "\"");
//	dotSyntax.put("jndi.syntax.beginquote2", "'");

        Name first = null;
	try {
	    for (int i = 0; i < args.length; i++) {
		Name name;
		Enumeration e;
		System.out.println("Given name: " + args[i]);
		name = new CompoundName(args[i], dotSyntax);
		if (first == null) {
		    first = name;
		}
		e = name.getComponents();
		while (e.hasMoreElements()) {
		    System.out.println("Element: " + e.nextElement());
		}
		System.out.println("Constructed name: " + name.toString());

		System.out.println("Compare " + first.toString() + " with "
		    + name.toString() + " = " + first.compareTo(name));
=6=

1|2|3|4|5| < PREV = PAGE 6 = NEXT > |7

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.0122662 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)