private void build(Document doc,Node root){
  Element file=doc.createElement("file");
  file.setAttribute("name",name);
  root.appendChild(file);
  if (copyright != null && !copyright.isEmpty())   appendTextElement(doc,file,"copyright",copyright);
  if (description != null && !description.isEmpty())   appendTextElement(doc,file,"description",description);
  for (  Entry<String,String> e : hash.entrySet()) {
    Element hash=doc.createElement("hash");
    hash.setAttribute("type",e.getKey());
    hash.appendChild(doc.createTextNode(e.getValue()));
    file.appendChild(hash);
  }
  if (identity != null && !identity.isEmpty())   appendTextElement(doc,file,"identity",identity);
  for (  String lang : language)   appendTextElement(doc,file,"language",lang);
  if (logo != null && !logo.isEmpty())   appendTextElement(doc,file,"logo",logo);
  for (  BasicElement be : metaUrls)   be.build(doc,file);
  for (  String os : this.os)   appendTextElement(doc,file,"os",os);
  if (publisher != null)   publisher.build(doc,file);
  if (signature != null)   signature.build(doc,file);
  if (size >= 0)   appendTextElement(doc,file,"size",String.valueOf(size));
  for (  BasicElement url : this.url)   url.build(doc,file);
  if (version != null && !version.isEmpty())   appendTextElement(doc,file,"version",version);
  for (  MetalinkFilePiecesBuilder pieces : this.pieces)   pieces.build(doc,file);
}

private void build ( Document doc , Node root ) { Element file = doc . createElement ( "file" ) ; file . setAttribute ( "name" , name ) ; root . appendChild ( file ) ; if ( copyright != null && ! copyright . isEmpty ( ) ) appendTextElement ( doc , file , "copyright" , copyright ) ; if ( description != null && ! description . isEmpty ( ) ) appendTextElement ( doc , file , "description" , description ) ; for ( Entry < String , String > e : hash . entrySet ( ) ) { Element hash = doc . createElement ( "hash" ) ; hash . setAttribute ( "type" , e . getKey ( ) ) ; hash . appendChild ( doc . createTextNode ( e . getValue ( ) ) ) ; file . appendChild ( hash ) ; } if ( identity != null && ! identity . isEmpty ( ) ) appendTextElement ( doc , file , "identity" , identity ) ; for ( String lang : language ) appendTextElement ( doc , file , "language" , lang ) ; if ( logo != null && ! logo . isEmpty ( ) ) appendTextElement ( doc , file , "logo" , logo ) ; for ( BasicElement be : metaUrls ) be . build ( doc , file ) ; for ( String os : this . os ) appendTextElement ( doc , file , "os" , os ) ; if ( publisher != null ) publisher . build ( doc , file ) ; if ( signature != null ) signature . build ( doc , file ) ; if ( size >= 0 ) appendTextElement ( doc , file , "size" , String . valueOf ( size ) ) ; for ( BasicElement url : this . url ) url . build ( doc , file ) ; if ( version != null && ! version . isEmpty ( ) ) appendTextElement ( doc , file , "version" , version ) ; for ( MetalinkFilePiecesBuilder pieces : this . pieces ) pieces . build ( doc , file ) ; }
creates a new file element and appends it to root node .
