Advertisement
Guest User

NDEBUG

a guest
Aug 4th, 2009
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.65 KB | None | 0 0
  1. // ****************************************************************************
  2. // **
  3. // ** Spieler.java
  4. // ** Description
  5. // **
  6. // ****************************************************************************
  7. package de.fussballmanager.data;
  8.  
  9. // ============================================================================
  10. // IMPLEMENTATION REQUIRED IMPORTS
  11. // ============================================================================
  12. import org.w3c.dom.Attr;
  13. import org.w3c.dom.NamedNodeMap;
  14. import org.w3c.dom.Node;
  15.  
  16. // ============================================================================
  17. // IMPLEMENTATION CLASS BODY
  18. // ============================================================================
  19. public class Spieler {
  20.     // ========================================================================
  21.     // IMPLEMENTATION PRIVATE CONSTANTS
  22.     // ========================================================================
  23.     // ========================================================================
  24.     // IMPLEMENTATION PUBLIC CONSTANTS
  25.     // ========================================================================
  26.     // ========================================================================
  27.     // IMPLEMENTATION PRIVATE DATA
  28.     // ========================================================================
  29.     // spieler specific instance variables
  30.     private String name;
  31.  
  32.     // instance variables for easy reading and writing of xml
  33.     private String filename;
  34.     private Node spielerNodeXML;
  35.  
  36.     // ========================================================================
  37.     // IMPLEMENTATION PUBLIC DATA
  38.     // ========================================================================
  39.     // ========================================================================
  40.     // IMPLEMENTATION PRIVATE METHODS
  41.     // ========================================================================
  42.     private void parseSpielerXML(Node spielerNodeXML) {
  43.         // store the node that belongs to the mannschaft
  44.         this.spielerNodeXML = spielerNodeXML;
  45.  
  46.         // get the attributes of the mannschaft node and extract what we need
  47.         try {
  48.             NamedNodeMap spielerAttributes = this.spielerNodeXML.getAttributes();
  49.             this.name = spielerAttributes.getNamedItem("name").getTextContent();
  50.         } catch (NullPointerException npEx) {
  51.             System.err.println("Error while parsing " + this.filename
  52.                     + " while reading the attributes of a spieler.");
  53.             System.err.println("There are missing spieler attributes.");
  54.             System.err.println("Required attributes are: \"name\".");
  55.             System.exit(4);
  56.         }
  57.     }
  58.  
  59.     // ========================================================================
  60.     // IMPLEMENTATION PUBLIC METHODS
  61.     // ========================================================================
  62.     public Spieler(String filename, Node spielerNodeXML) {
  63.         // store the filename to this liga's xml file
  64.         this.filename = filename;
  65.  
  66.         // parse the node and extract all informations we need
  67.         this.parseSpielerXML(spielerNodeXML);
  68.     }
  69.  
  70.     // getters/setters
  71.     public String getName() {
  72.         return this.name;
  73.     }
  74.  
  75.     public void setName(String name) {
  76.         Attr attribute = (Attr) this.spielerNodeXML.getAttributes().getNamedItem(
  77.                 "name");
  78.         attribute.setValue(name);
  79.         this.name = name;
  80.     }
  81. }
  82. // ****************************************************************************
  83. // **
  84. // ** Spieler.java
  85. // **
  86. // ****************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement