1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * %W% %E%
 * 
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.sun.deploy.xml;
import java.util.ArrayList;
import java.net.URL;

/** Utility class for constructing XMLAttribute lists
 */
public class XMLAttributeBuilder {
    private XMLAttribute _root;
    private XMLAttribute _next;
    
    public XMLAttributeBuilder() {
    _root = null;
    }
    
    public void add(XMLAttribute attr) {
    if (attr != null) {
        if (_next == null) {
        _root = _next = attr;
        attr.setNext(null);
        } else {
        _next.setNext(attr);
        _next = attr;
        attr.setNext(null);
        }
    }
    }
    
    /** Add a string attribute to the list. NULL arguments are ignored */
    public void add(String name, String value) {
    if (value != null && value.length() > 0) {
        add(new XMLAttribute(name, value));
    }
    }
    
    /** Add a URL attribute to the list. NULL arguments are ignored */
    public void add(String name, URL value) {
    if (value != null) {
        add(new XMLAttribute(name, value.toString()));
    }
    }
    
    /** Add an integer attribute to the list. NULL arguments are ignored */
    public void add(String name, long value) {
    if (value != 0) {
        add(new XMLAttribute(name, new Long(value).toString()));
    }
    }
    
    /** Add an boolean attribute to the list. NULL arguments are ignored */
    public void add(String name, boolean value) {
    add(new XMLAttribute(name, (value) ? "true" : "false" ));
    }
    
    /** Returns list of all added attributes in the right order*/
    public XMLAttribute getAttributeList() { return _root; }
}


			
			

Browsed Source: [clear]