FTP-Server API

setup
Class XMLTag

java.lang.Object
  |
  +--setup.XMLTag

public class XMLTag
extends Object

The class represents a Tag as fx. <TAG>. The whole idea, is to make a dynamical XML-structure. Typically the class is made through an XMLParser, by instantiating the XMLParser, and using its "main-tag"

XMLParser parser = new XMLParser(new File("setup.conf"));
XMLTag xml = parser.XML;

Some of the classes documentation builds on the following example.

#Serversetup
<Server>
  Port 21
</Server>

#Users on the server!
<Users>
  <User>
    name Kenneth Vindum
    login lkv
    pass pkv
  </User>
  <User>
    name John Doe
    login lsr
    pass psr
  </User>
</Users>


Field Summary
 String tagName
          The name of the tag
 
Constructor Summary
XMLTag(String tagName)
          Set-constructor.
 
Method Summary
 void addComment(String comment)
          Adds a comment to the tag.
protected  void addCommentFromFile(String comment)
          Adds a comment to the tag while reading a file.
 void addOption(String optionName, String optionValue)
          Adds an option to a Tag.
 void addTag(XMLTag newTag)
          Adds a new tag to this tag.
protected  XMLTag addTagFromFile(String tagName)
          Adds a sub-Tag to this tag.
protected  boolean endTag(String tagName)
          Ends a tag, that has been readen from a file.
 String getOptionValue(String optionName)
          Gets the value of an option in this tag.
 XMLTag getParent()
          The tag, that this tag has been addd to.
 String getQuickOptionValue(String optionName)
          Quick way to find a value from tag-string of a certain syntax (Users.User.name)
 XMLTag[] getSubTags()
          Returns all the subTags of this class.
 XMLTag getTagLike(String tagName)
          Finds the first tag, that has the passed name.
 XMLTag[] getTagsLike(String tagName)
          Finds all tags, that has the passed Name, Syntax (Users.User).
 String getXMLString()
          Henter hele XML strukturen fra dette tag og nedefter (i sub-Tags).
 void removeOption(String optionName)
          Deletes an option from the Tag.
 boolean removeTag(XMLTag oldTag)
          Removes a tag from this tag.
 void setOptionValue(String optionName, String optionValue)
          Sets the value of an option in this tag.
 void setQuickOptionValue(String optionName, String optionValue)
          Sets the value of an option.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tagName

public String tagName
The name of the tag

Constructor Detail

XMLTag

public XMLTag(String tagName)
Set-constructor.

Parameters:
tagName - The name of the tag
Method Detail

addOption

public void addOption(String optionName,
                      String optionValue)
Adds an option to a Tag. Fx. [FTPServerport 21], where optionName = FTPServerport, og optionValue=21

Parameters:
optionName - The options name
optionValue - The options value

removeOption

public void removeOption(String optionName)
                  throws NoSuchOptionException
Deletes an option from the Tag.

Parameters:
optionName - The name of the option that should be deleted!
NoSuchOptionException

addComment

public void addComment(String comment)
Adds a comment to the tag. The method adds "#" in front of the tag, if it is not allready there.

Parameters:
comment - The comment

addCommentFromFile

protected void addCommentFromFile(String comment)
Adds a comment to the tag while reading a file.

Parameters:
comment - The comment

setOptionValue

public void setOptionValue(String optionName,
                           String optionValue)
                    throws NoSuchOptionException
Sets the value of an option in this tag.

Parameters:
optionName - the name of an option
optionValue - The new value of this option
Throws:
NoSuchOptionException - If the option are not found, an exception is thrown.

setQuickOptionValue

public void setQuickOptionValue(String optionName,
                                String optionValue)
                         throws NoSuchTagException
Sets the value of an option. The syntax for the method is (Users.User.name)

Parameters:
optionName - the options name (and XMLTags to it)
optionValue - The new value of this option
Throws:
NoSuchTagException - If the option are not found, an exception is thrown.

getOptionValue

public String getOptionValue(String optionName)
                      throws NoSuchOptionException
Gets the value of an option in this tag.

Parameters:
optionName - The name of the option witch value is requested.
Returns:
value
Throws:
NoSuchOptionException - If the option are not found, an exception is thrown.

getQuickOptionValue

public String getQuickOptionValue(String optionName)
                           throws NoSuchTagException
Quick way to find a value from tag-string of a certain syntax (Users.User.name)

Parameters:
optionName - The path from this tag, to the wished tag, along with the optionName (Users.User.name)
Returns:
value
Throws:
NoSuchTagException - if one of the tags, or the option are not found, an exception is thrown

getTagsLike

public XMLTag[] getTagsLike(String tagName)
                     throws NoSuchTagException
Finds all tags, that has the passed Name, Syntax (Users.User).

Parameters:
tagName - the tags name
Returns:
All qualyfied tags in an array[].
Throws:
NoSuchTagException - If no tags are found with the passed name.

getTagLike

public XMLTag getTagLike(String tagName)
                  throws NoSuchTagException
Finds the first tag, that has the passed name. Syntax (Users.User).

Parameters:
tagName - the name of tag that is searched for
Returns:
the teg
Throws:
NoSuchTagException - If the tag are not found.

getSubTags

public XMLTag[] getSubTags()
Returns all the subTags of this class.

Returns:
an empty array if no tags are found.

getXMLString

public String getXMLString()
Henter hele XML strukturen fra dette tag og nedefter (i sub-Tags). Strukturen retuneres pænt opsat, og klar til at blive skrevet i en fil.

Returns:
XML dokument.

addTagFromFile

protected XMLTag addTagFromFile(String tagName)
Adds a sub-Tag to this tag.
<TAG>   <SUBTAG>   </SUBTAG> </TAG>

Parameters:
tagName - The name of the sub-Tag
Returns:
nyt Tag

getParent

public XMLTag getParent()
The tag, that this tag has been addd to.

Returns:
null, if there are no parent tag.

addTag

public void addTag(XMLTag newTag)
Adds a new tag to this tag.

Parameters:
newTag - the new tag.

removeTag

public boolean removeTag(XMLTag oldTag)
Removes a tag from this tag.

Parameters:
oldTag - the tag that is to be removed

endTag

protected boolean endTag(String tagName)
Ends a tag, that has been readen from a file. States that a following tag may be inserted.

Parameters:
tagName - The name of the tag, that shall be ended.
Returns:
false, if the tag cannot be ended!

FTP-Server API