1 23 package org.objectweb.clif.scenario.util.isac.util.tree; 24 25 import java.io.FileInputStream ; 26 import java.util.Hashtable ; 27 import java.util.Vector ; 28 29 import javax.xml.parsers.DocumentBuilder ; 30 import javax.xml.parsers.DocumentBuilderFactory ; 31 32 import org.apache.log4j.Category; 33 import org.objectweb.clif.scenario.util.isac.loadprofile.GroupDescription; 34 import org.objectweb.clif.scenario.util.isac.loadprofile.LoadProfileManager; 35 import org.objectweb.clif.scenario.util.isac.loadprofile.Point; 36 import org.objectweb.clif.scenario.util.isac.loadprofile.RampDescription; 37 import org.objectweb.clif.scenario.util.isac.loadprofile.gui.Size; 38 import org.objectweb.clif.scenario.util.isac.plugin.PluginManager; 39 import org.objectweb.clif.scenario.util.isac.util.tree.nodes.ChoiceNode; 40 import org.objectweb.clif.scenario.util.isac.util.tree.nodes.ControlerNode; 41 import org.w3c.dom.Document ; 42 import org.w3c.dom.Element ; 43 import org.w3c.dom.NamedNodeMap ; 44 import org.w3c.dom.Node ; 45 import org.w3c.dom.NodeList ; 46 import org.xml.sax.InputSource ; 47 48 55 public class LoadScenario { 56 static Category cat = Category.getInstance(LoadScenario.class.getName()); 57 58 static PluginManager pluginManager = PluginManager.getPluginManager(); 59 60 private static TreeManager treeManager = TreeManager.getTreeManager(null); 61 62 private static LoadProfileManager loadProfileManager = LoadProfileManager 63 .getInstance(); 64 65 private static NodeDescription currentDesc = null; 66 67 private static String currentControllerType = null; 68 69 private static ScenarioNode tree = null; 70 71 private static ScenarioNode lastControllerNode = null; 72 73 private static String currentGroupId = null; 74 75 private static RampDescription currentRamp = null; 76 77 private static Point currentEnd = null; 78 79 private static Point currentStart = null; 80 81 private static Point lastEnd = null; 82 83 private static Size maxScale = new Size(0,0) ; 84 85 101 private static boolean visit(ScenarioNode parent, 102 boolean isControllerChild, Node node, Hashtable nodes, Vector errors) { 103 ScenarioNode result = null; 104 105 boolean flag = false; 107 String tagName = null; 108 switch (node.getNodeType()) { 109 case Node.ELEMENT_NODE: 110 tagName = ((Element ) node).getTagName(); 111 if (tagName 112 .equals(org.objectweb.clif.scenario.util.isac.util.tree.Node.BEHAVIORS)) { 113 NodeDescription desc = NodeDescription 114 .createNonePluginNode(org.objectweb.clif.scenario.util.isac.util.tree.Node.BEHAVIORS); 115 int keyInt = desc.hashCode(); 117 while (nodes.containsKey(new String ((new Integer (keyInt)) 119 .toString()))) 120 keyInt++; 121 nodes.put(new String ((new Integer (keyInt)).toString()), desc); 123 result = new ScenarioNode(new String ((new Integer (keyInt)) 125 .toString())); 126 tree = result; 128 } else if (tagName 129 .equals(org.objectweb.clif.scenario.util.isac.util.tree.Node.BEHAVIOR)) { 130 NodeDescription desc = NodeDescription 132 .createNonePluginNode(org.objectweb.clif.scenario.util.isac.util.tree.Node.BEHAVIOR); 133 134 NamedNodeMap attributs = node.getAttributes(); 135 if (attributs.getLength() < 1) { 137 errors.add("WARNING:" + "The node \"" + tagName 138 + "\" must define an attribute \"id\""); 139 140 } else { 141 Node id = attributs.getNamedItem("id"); 142 if (id == null) { 143 errors 144 .add("WARNING:" 145 + "The attribute \"id\" is not defined in a node " 146 + tagName); 147 } else { 148 String idValue = id.getNodeValue(); 149 if (idValue.equals("")) { 150 errors 151 .add("WARNING:" 152 + "The attribute \"id\" is not initialised in a node " 153 + tagName); 154 } else { 155 if (!treeManager.getBehaviorsIds() 157 .contains(idValue)) { 158 desc.getParams().remove("id"); 160 desc.getParams().put("id", idValue); 161 cat.debug("ID OF THE BEHAVIOR="+idValue) ; 162 } 163 else { 164 errors.add("ERROR: The value of this behavior id already exist : " + idValue) ; 165 } 166 } 167 } 168 } 169 int keyInt = desc.hashCode(); 171 while (nodes.containsKey(new String ((new Integer (keyInt)) 173 .toString()))) 174 keyInt++; 175 nodes.put(new String ((new Integer (keyInt)).toString()), desc); 177 result = new ScenarioNode(new String ((new Integer (keyInt)) 179 .toString())); 180 } else if (org.objectweb.clif.scenario.util.isac.util.tree.Node.USE 181 .equals(tagName)) { 182 NamedNodeMap attributs = node.getAttributes(); 183 if (attributs.getLength() < 2) { 185 errors 186 .add("ERROR:" 187 + "The node \"" 188 + tagName 189 + "\" must define two parameters, \"id\" and \"name\""); 190 return false; 191 } 192 Node id = attributs.getNamedItem("id"); 193 if (id == null) { 194 errors 195 .add("ERROR:" 196 + "The parameter \"id\" is not defined in the node " 197 + tagName); 198 return false; 199 } 200 String idValue = id.getNodeValue(); 201 if (idValue.equals("")) { 202 errors 203 .add("ERROR:" 204 + "The parameter \"id\" is not initialised in the node " 205 + tagName); 206 return false; 207 } 208 Node name = attributs.getNamedItem("name"); 209 if (name == null) { 210 errors 211 .add("ERROR:" 212 + "The parameter \"name\" is not defined in the node " 213 + tagName); 214 return false; 215 } 216 String nameValue = name.getNodeValue(); 217 if (nameValue.equals("")) { 218 errors 219 .add("ERROR:" 220 + "The parameter \"name\" is not intialised in the node " 221 + tagName); 222 return false; 223 } 224 Vector descs = pluginManager.createNodesDescriptions(tagName); 225 NodeDescription desc = null; 226 for (int i = 0; i < descs.size(); i++) { 227 if (((NodeDescription) descs.elementAt(i)).getPlugin() 228 .equals(nameValue)) 229 desc = (NodeDescription) descs.elementAt(i); 230 } 231 if (desc == null) { 232 errors.add("ERROR:" 233 + "The plugin used could not be found : " 234 + nameValue); 235 return false; 236 } 237 Hashtable params = desc.getParams(); 239 params.remove("id"); 240 params.put("id", idValue); 241 242 currentDesc = desc; 245 int keyInt = desc.hashCode(); 247 while (nodes.containsKey(new String ((new Integer (keyInt)) 249 .toString()))) 250 keyInt++; 251 nodes.put(new String ((new Integer (keyInt)).toString()), desc); 253 result = new ScenarioNode(new String ((new Integer (keyInt)) 255 .toString())); 256 } else if (org.objectweb.clif.scenario.util.isac.util.tree.Node 257 .isPluginNode(tagName)) { 258 NamedNodeMap attributs = node.getAttributes(); 259 if (attributs.getLength() < 2) { 261 errors 262 .add("ERROR:" 263 + "The node \"" 264 + tagName 265 + "\" must define two parameters, \"use\" and \"name\""); 266 return false; 267 } 268 Node use = attributs.getNamedItem("use"); 269 if (use == null) { 270 errors 271 .add("ERROR:" 272 + "The parameter \"use\" is not defined in the node " 273 + tagName); 274 return false; 275 } 276 String useValue = use.getNodeValue(); 277 if (useValue.equals("")) { 278 errors 279 .add("ERROR:" 280 + "The parameter \"use\" is not initialised in the node " 281 + tagName); 282 return false; 283 } 284 Node name = attributs.getNamedItem("name"); 285 if (name == null) { 286 errors 287 .add("ERROR:" 288 + "The parameter \"name\" is not defined in the node " 289 + tagName); 290 return false; 291 } 292 String nameValue = name.getNodeValue(); 293 if (nameValue.equals("")) { 294 errors 295 .add("ERROR:" 296 + "The parameter \"name\" is not intialised in the node " 297 + tagName); 298 return false; 299 } 300 Hashtable usedPlugins = TreeManager.getUsedPlugins(nodes); 301 if (!usedPlugins.containsKey(useValue)) { 302 errors 303 .add("ERROR:" 304 + "The plugin used in this action could not be found : " 305 + useValue); 306 return false; 307 } else { 308 NodeDescription descPlugin = (NodeDescription) usedPlugins 309 .get(useValue); 310 String pluginName = descPlugin.getPlugin(); 311 NodeDescription desc = pluginManager.createNodeDescription( 312 pluginName, tagName, nameValue); 313 currentDesc = desc; 316 Hashtable params = currentDesc.getParams(); 318 if (params != null) { 319 if (params.containsKey("id")) { 320 params.remove("id"); 322 params.put("id", useValue); 323 } 324 } 325 int keyInt = desc.hashCode(); 327 while (nodes.containsKey(new String ((new Integer (keyInt)) 329 .toString()))) 330 keyInt++; 331 nodes.put(new String ((new Integer (keyInt)).toString()), 333 desc); 334 result = new ScenarioNode(new String ((new Integer (keyInt)) 336 .toString())); 337 } 338 } else if (tagName 339 .equals(org.objectweb.clif.scenario.util.isac.util.tree.Node.PARAMS)) { 340 } else if (tagName 342 .equals(org.objectweb.clif.scenario.util.isac.util.tree.Node.PARAM)) { 343 NamedNodeMap attributs = node.getAttributes(); 344 if (attributs.getLength() < 2) { 346 errors 347 .add("ERROR:" 348 + "The node \"" 349 + tagName 350 + "\" must define two parameters, \"name\" and \"value\""); 351 return false; 352 } 353 Node name = attributs.getNamedItem("name"); 354 if (name == null) { 355 errors 356 .add("ERROR:" 357 + "The parameter \"name\" is not defined in the node " 358 + tagName); 359 return false; 360 } 361 String nameValue = name.getNodeValue(); 362 if (nameValue.equals("")) { 363 errors 364 .add("ERROR:" 365 + "The parameter \"name\" is not initialised in the node " 366 + tagName); 367 return false; 368 } 369 Node value = attributs.getNamedItem("value"); 370 if (value == null) { 371 errors 372 .add("ERROR:" 373 + "The parameter \"value\" is not defined in the node " 374 + tagName); 375 return false; 376 } 377 String valueValue = value.getNodeValue(); 378 if (valueValue.equals("")) { 379 errors 380 .add("WARNING:" 381 + "The parameter \"value\" is not intialised in the node " 382 + tagName); 383 } 384 if (currentDesc != null) { 385 Hashtable params = currentDesc.getParams(); 386 if (params != null) { 387 if (params.containsKey(nameValue)) { 388 params.remove(nameValue); 390 params.put(nameValue, valueValue); 391 } 392 } 393 } 394 } else if (org.objectweb.clif.scenario.util.isac.util.tree.Node 395 .isControllerNode(tagName)) { 396 currentControllerType = tagName; 398 flag = true; 399 } else if (org.objectweb.clif.scenario.util.isac.util.tree.Node.CONDITION 400 .equals(tagName)) { 401 if (currentControllerType != null) { 402 NamedNodeMap attributs = node.getAttributes(); 403 if (attributs.getLength() < 2) { 405 errors 406 .add("ERROR:" 407 + "The node \"" 408 + tagName 409 + "\" must define two parameters, \"use\" and \"name\""); 410 return false; 411 } 412 Node use = attributs.getNamedItem("use"); 413 if (use == null) { 414 errors 415 .add("ERROR:" 416 + "The parameter \"use\" is not defined in the node " 417 + tagName); 418 return false; 419 } 420 String useValue = use.getNodeValue(); 421 if (useValue.equals("")) { 422 errors 423 .add("ERROR:" 424 + "The parameter \"use\" is not initialised in the node " 425 + tagName); 426 return false; 427 } 428 Node name = attributs.getNamedItem("name"); 429 if (name == null) { 430 errors 431 .add("ERROR:" 432 + "The parameter \"name\" is not defined in the node " 433 + tagName); 434 return false; 435 } 436 String nameValue = name.getNodeValue(); 437 if (nameValue.equals("")) { 438 errors 439 .add("ERROR:" 440 + "The parameter \"name\" is not intialised in the node " 441 + tagName); 442 return false; 443 } 444 Hashtable usedPlugins = TreeManager.getUsedPlugins(nodes); 445 if (!usedPlugins.containsKey(useValue)) { 446 errors 447 .add("ERROR: Unable to find the plugin which is used by this action : " 448 + useValue); 449 return false; 450 } else { 451 NodeDescription descPlugin = (NodeDescription) usedPlugins 452 .get(useValue); 453 String pluginName = descPlugin.getPlugin(); 454 NodeDescription desc = ControlerNode 455 .createNodeDescription(pluginName, 456 currentControllerType, nameValue); 457 currentDesc = desc; 460 Hashtable params = currentDesc.getParams(); 462 if (params != null) { 463 if (params.containsKey("id")) { 464 params.remove("id"); 466 params.put("id", useValue); 467 } 468 } 469 int keyInt = desc.hashCode(); 471 while (nodes.containsKey(new String ( 473 (new Integer (keyInt)).toString()))) 474 keyInt++; 475 nodes.put(new String ((new Integer (keyInt)).toString()), 477 desc); 478 result = new ScenarioNode(new String ((new Integer ( 480 keyInt)).toString())); 481 currentControllerType = null; 483 } 484 } 485 } else if (org.objectweb.clif.scenario.util.isac.util.tree.Node.CHOICE 486 .equals(tagName)) { 487 NamedNodeMap attributs = node.getAttributes(); 488 if (attributs.getLength() < 1) { 490 errors 491 .add("ERROR:" 492 + "The node \"" 493 + tagName 494 + "\" must define one parameter, \"proba\""); 495 return false; 496 } 497 Node proba = attributs.getNamedItem("proba"); 498 if (proba == null) { 499 errors 500 .add("ERROR:" 501 + "The parameter \"proba\" is not defined in the node " 502 + tagName); 503 return false; 504 } 505 String probaValue = proba.getNodeValue(); 506 if (probaValue.equals("")) { 507 errors 508 .add("WARNING:" 509 + "The parameter \"proba\" is not initialised in the node " 510 + tagName); 511 } 512 513 NodeDescription desc = ChoiceNode.createNodeDescription(); 514 currentDesc = desc; 515 Hashtable params = currentDesc.getParams(); 517 if (params != null) { 518 if (params.containsKey("proba")) { 519 params.remove("proba"); 521 params.put("proba", probaValue); 522 } 523 } 524 int keyInt = desc.hashCode(); 525 while (nodes.containsKey(new String ((new Integer (keyInt)) 527 .toString()))) 528 keyInt++; 529 nodes.put(new String ((new Integer (keyInt)).toString()), desc); 531 result = new ScenarioNode(new String ((new Integer (keyInt)) 533 .toString())); 534 } 535 else if (org.objectweb.clif.scenario.util.isac.util.tree.Node.LOAD_PROFILE 537 .equals(tagName)) { 538 } else if (org.objectweb.clif.scenario.util.isac.util.tree.Node.GROUP 540 .equals(tagName)) { 541 NamedNodeMap attributs = node.getAttributes(); 543 if (attributs.getLength() < 1) { 545 errors 546 .add("ERROR:" 547 + "The node \"" 548 + tagName 549 + "\" must define at least one parameter, \"behavior\""); 550 return false; 551 } 552 Node behavior = attributs.getNamedItem("behavior"); 553 if (behavior == null) { 554 errors 555 .add("ERROR:" 556 + "The parameter \"behavior\" is not defined in the node " 557 + tagName); 558 return false; 559 } 560 String behaviorValue = behavior.getNodeValue(); 561 if (behaviorValue.equals("")) { 562 errors 563 .add("ERROR:" 564 + "The parameter \"behavior\" is not initialised in the node " 565 + tagName); 566 return false; 567 } 568 Node forceStop = attributs.getNamedItem("forceStop"); 569 String forceValue = ""; 570 if (forceStop != null) { 571 forceValue = forceStop.getNodeValue(); 572 } 573 if (treeManager.getBehaviorsIds().contains(behaviorValue)) { 575 currentGroupId = loadProfileManager.groupIdGenerator(); 577 GroupDescription gd = new GroupDescription(currentGroupId); 579 gd.setBehaviorId(behaviorValue); 580 if (forceValue.equals("false")) { 582 gd.setForceStop(false); 583 } 584 gd.setCurveColor(loadProfileManager.getDefaultColor()); 586 loadProfileManager.addGroupDescription(gd); 588 } 589 else { 590 errors.add("ERROR: Don't find the behavior used in this group -> " + behaviorValue) ; 591 return false ; 592 } 593 lastEnd = null; 595 currentEnd = null; 596 currentStart = null; 597 } else if (org.objectweb.clif.scenario.util.isac.util.tree.Node.RAMP 598 .equals(tagName)) { 599 if (currentGroupId == null) { 602 errors 603 .add("WARNING : There a ramp defined outside a group description, ignore it..."); 604 return true; 605 } else { 606 NamedNodeMap attributs = node.getAttributes(); 608 if (attributs.getLength() < 1) { 610 errors.add("ERROR:" + "The node \"" + tagName 611 + "\" must define one parameter, \"style\""); 612 return false; 613 } 614 Node style = attributs.getNamedItem("style"); 615 if (style == null) { 616 errors 617 .add("ERROR:" 618 + "The parameter \"style\" is not defined in the node " 619 + tagName); 620 return false; 621 } 622 String styleValue = style.getNodeValue(); 623 if (styleValue.equals(RampDescription.LINE_STRING)) { 625 String rampId = loadProfileManager.rampIdGenerator(); 626 currentRamp = new RampDescription(rampId, 627 RampDescription.LINE); 628 } else if (styleValue.equals(RampDescription.ARC_STRING)) { 629 String rampId = loadProfileManager.rampIdGenerator(); 630 currentRamp = new RampDescription(rampId, 631 RampDescription.ARC); 632 } else if (styleValue 633 .equals(RampDescription.CRENEL_VH_STRING)) { 634 String rampId = loadProfileManager.rampIdGenerator(); 635 currentRamp = new RampDescription(rampId, 636 RampDescription.CRENEL_VH); 637 } else if (styleValue 638 .equals(RampDescription.CRENEL_HV_STRING)) { 639 String rampId = loadProfileManager.rampIdGenerator(); 640 currentRamp = new RampDescription(rampId, 641 RampDescription.CRENEL_HV); 642 } 643 else { 645 errors.add("WARNING : This style : " + styleValue 646 + ", is unknow..."); 647 return false; 648 } 649 } 650 } else if (org.objectweb.clif.scenario.util.isac.util.tree.Node.POINTS 651 .equals(tagName)) { 652 lastEnd = currentEnd; 655 currentEnd = null; 656 currentStart = null; 657 } else if (org.objectweb.clif.scenario.util.isac.util.tree.Node.POINT 658 .equals(tagName)) { 659 if (currentRamp == null) { 661 errors 662 .add("WARNING : There is a point defined outside a ramp description, ignore it..."); 663 return true; 664 } else { 665 NamedNodeMap attributs = node.getAttributes(); 667 if (attributs.getLength() < 3) { 669 errors 670 .add("ERROR:" 671 + "The node \"" 672 + tagName 673 + "\" must define three parameters, \"name\" \"x\" \"y\""); 674 return false; 675 } 676 Node name = attributs.getNamedItem("name"); 677 if (name == null) { 678 errors 679 .add("ERROR:" 680 + "The parameter \"name\" is not defined in the node " 681 + tagName); 682 return false; 683 } 684 String nameValue = name.getNodeValue(); 685 if (nameValue.equals("")) { 686 errors 687 .add("ERROR:" 688 + "The parameter \"name\" is not initialised in the node " 689 + tagName); 690 return false; 691 } 692 Node xNode = attributs.getNamedItem("x"); 693 if (xNode == null) { 694 errors 695 .add("ERROR:" 696 + "The parameter \"x\" is not defined in the node " 697 + tagName); 698 return false; 699 } 700 String xAxis = xNode.getNodeValue(); 701 if (xAxis.equals("")) { 702 errors 703 .add("ERROR:" 704 + "The parameter \"x\" is not initialised in the node " 705 + tagName); 706 return false; 707 } 708 Node yNode = attributs.getNamedItem("y"); 709 if (yNode == null) { 710 errors 711 .add("ERROR:" 712 + "The parameter \"y\" is not defined in the node " 713 + tagName); 714 return false; 715 } 716 String yAxis = yNode.getNodeValue(); 717 if (yAxis.equals("")) { 718 errors 719 .add("ERROR:" 720 + "The parameter \"y\" is not initialised in the node " 721 + tagName); 722 return false; 723 } 724 725 Integer xAxisInteger = new Integer (xAxis); 726 Integer yAxisInteger = new Integer (yAxis); 727 if (nameValue.equals(RampDescription.POINT_START)) { 729 currentStart = new Point(xAxisInteger.intValue(), 733 yAxisInteger.intValue()); 734 735 if (lastEnd != null) { 737 if (!lastEnd.equals(currentStart)) { 738 errors 739 .add("ERROR : A ramp have a starting point which is not the same than the previous ramp ending point !"); 740 return false; 741 } 742 } 743 if (currentEnd != null) { 744 if (currentStart.x >= currentEnd.x) { 747 errors 748 .add("ERROR : The starting point is after the ending point in the time scale !"); 749 return false; 750 } 751 currentRamp.setStart(currentStart); 754 currentRamp.setEnd(currentEnd); 755 loadProfileManager.addRampDescriptionToGroup( 758 currentRamp, currentGroupId); 759 } 760 } else if (nameValue.equals(RampDescription.POINT_END)) { 761 currentEnd = new Point(xAxisInteger.intValue(), 763 yAxisInteger.intValue()); 764 if (currentStart != null) { 765 if (currentStart.x >= currentEnd.x) { 768 errors 769 .add("ERROR : The starting point is after the ending point in the time scale ! "); 770 return true; 771 } 772 currentRamp.setStart(currentStart); 775 currentRamp.setEnd(currentEnd); 776 loadProfileManager.addRampDescriptionToGroup( 778 currentRamp, currentGroupId); 779 } 780 781 } else if (nameValue.equals(RampDescription.POINT_ANGLE)) { 782 errors 784 .add("WARNING : The ramp is a "+currentRamp.getType()+" and does not need any angle point, so ignore it !"); 785 return true; 786 } 789 else { 790 errors 791 .add("WARNING : The ramp is a "+currentRamp.getType()+" and does not need any "+nameValue+" point, so ignore it !"); 792 return true; 793 } 794 if (xAxisInteger.intValue() > maxScale.getWidth()) { 796 maxScale.setWidth(xAxisInteger.intValue()) ; 797 } 798 if (yAxisInteger.intValue() > maxScale.getHeight()) { 799 maxScale.setHeight(yAxisInteger.intValue()) ; 800 } 801 } 802 } 803 804 else { 806 NodeDescription desc = NodeDescription 807 .createNonePluginNode(tagName); 808 int keyInt = desc.hashCode(); 810 while (nodes.containsKey(new String ((new Integer (keyInt)) 812 .toString()))) 813 keyInt++; 814 nodes.put(new String ((new Integer (keyInt)).toString()), desc); 816 result = new ScenarioNode(new String ((new Integer (keyInt)) 818 .toString())); 819 } 820 break; 821 default: 822 } 824 if ((result != null) && (parent != null)) { 826 if (isControllerChild) { 828 if (lastControllerNode != null) 830 lastControllerNode.addChild(result); 831 else { 832 parent.addChild(result); 833 parent.printTest(); 834 lastControllerNode = result; 835 } 836 } else 837 parent.addChild(result); 838 } 839 840 if (node.hasChildNodes()) { 841 NodeList fils = node.getChildNodes(); 842 for (int i = 0; i < fils.getLength(); i++) { 843 Node tempNode = fils.item(i); 844 if (tempNode.getNodeType() == Node.ELEMENT_NODE) { 845 boolean continueProcess = true; 846 if (result != null) { 847 continueProcess = visit(result, flag, tempNode, nodes, 848 errors); 849 } else { 850 continueProcess = visit(parent, flag, tempNode, nodes, 851 errors); 852 } 853 if (!continueProcess) 855 return false; 856 } 857 } 858 } 859 if (tagName != null) 861 if (org.objectweb.clif.scenario.util.isac.util.tree.Node 863 .isControllerNode(tagName)) { 864 lastControllerNode = null; 865 } 866 867 return true; 868 } 869 870 880 public static ScenarioNode loadScenario(String fileName, Hashtable nodes, 881 Vector errors) { 882 Document document = null; 883 try { 884 InputSource is = new InputSource (new FileInputStream (fileName)); 885 DocumentBuilderFactory factory = DocumentBuilderFactory 886 .newInstance(); 887 DocumentBuilder builder = factory.newDocumentBuilder(); 888 document = builder.parse(is); 889 } catch (Exception e) { 890 errors.add(e.toString()); 891 return null; 892 } 893 if (visit(null, false, document, nodes, errors)) { 895 if (maxScale.getWidth() != 0 && maxScale.getHeight() != 0) { 897 loadProfileManager.setScale(maxScale) ; 899 } 900 return tree; 901 } 902 else 903 return null; 904 } 905 } | Popular Tags |