Click here to Skip to main content
15,884,176 members
Articles / Programming Languages / Java

XML: Generic File Writing and Loading Library

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
16 May 2011CPOL8 min read 22.7K   350   14  
Generic XML Tool to save and load XML files in a defined XML Format - useful for application settings or data
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-520 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2011.03.15 at 12:44:42 PM MEZ 
//


package jhtools.xml.generic.modelbinding;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import jhtools.xml.generic.IGeneric;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "tag")
public class Tag implements IGeneric, Cloneable {

    @XmlAttribute(required = true)
    protected String value;

    /**
     * Gets the value of the value property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getValue() {
        return value;
    }

    /**
     * Sets the value of the value property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setValue(String value) {
        this.value = value;
    }
    
    @Override
    public void add(IGeneric item) {
    	// nix    	
    }
    
    @Override
    public boolean delete(IGeneric object) {
    	return false;
    }

    @Override
    public IGeneric findGenericImage() {
    	return null;
    }
    
    @Override
    public IGeneric[] getChildren() {
    	return new IGeneric[0];
    }
    
    @Override
    public IGeneric[] getGenericData() {
    	return new IGeneric[0];
    }
    
    @Override
    public String getGenericKey() {
       	return this.value;
    }
    
    @Override
    public String getGenericName() {
    	return this.value;
    }
    
    @Override
    public Type getGenericType() {
    	return null;
    }
    
    @Override
    public IGeneric getImageByKey(String key) {
    	return null;
    }
    
    @Override
    public boolean isCategory() {
    	return false;
    }
    
    @Override
    public boolean isEntry() {
    	return false;
    }
    
	@Override
	public boolean isItem() {
		return false;
	}
	
	@Override
	public boolean isTag() {
		return true;
	}
	@Override
	public boolean isData() {
		return false;
	}
	
	@Override
	public List<IGeneric> matches(String regex) {	
		// return value List
		List<IGeneric> result = new ArrayList<IGeneric>();
		
		if (this.value.matches(regex)) {
			result.add(this);
		}
		return result;
	}
	@Override
	public void setGenericKey(String key) {}
	
	@Override
	public void setGenericName(String name) {
		this.value=name;		
	}
	@Override
	public void setGenericType(Type type) {}


	@Override
	public String toString(boolean recursive) {
    	return "Tag: name="+this.value+"\n";
	}
	
    @Override
    public String toString() {
    	return this.toString(true);
    }
	
	@Override
	public Object clone() throws CloneNotSupportedException {
		Tag tag = new Tag();
		tag.value = new String (this.value);		
		return tag;

	}
	
	@Override
	public List<IGeneric> findByTags(String[] tags) {
		return  new ArrayList<IGeneric> (0);
	}
	
	/**
	 * Is this Tag matching the given tag strings?
	 * @param tags String[]
	 * @return boolean
	 */
    protected boolean isTaggedByString (String[] tags) {
		if (tags!=null) {
			for (int i=0; i<tags.length; i++) {
				if (this.value.matches(tags[i])) return true;
			}
		}
		return false;
	}
    
    @Override
    public String[] getTags() {
    	return new String[0];
    }
    
    @Override
    public List<IGeneric> findChildrenByKey(String key, boolean recursive) {
    	return new ArrayList<IGeneric> (0);
    }
    
    @Override
    public List<IGeneric> getAllChildren() {    	
    	return new ArrayList<IGeneric> (0);
    }
    
    @Override
	public List<IGeneric> deleteChildrenWithKey(String key, boolean recursive) {
		return new ArrayList<IGeneric> (0);
	}
    
    @Override
    public List<IGeneric> deleteTags() {
    	return new ArrayList<IGeneric> (0);
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Database Developer
Germany Germany
I am programming more or less since I was 15 years.
It started with BASIC and during school I did
a lot Pascal programs for MS DOS.
After that I came to visual Windows programming and coded a lot in Delphi and later in C# .NET.
I made also some excursions in C and C++.

I also like Perl, Python and other scripting languages.
After a long break not programming anything, the last approx. 5-6 years I am only working with Java and SQL.

New for me is Objective-C - I am starting to get involved into Mac Programming Smile | :)

Comments and Discussions