Jump to content
  • 0

Convert IXMLReader code to XMLDocument


Question

Posted

Hello friends, I'm converting a code made in IXMLReader to XMLDocument because my entire source uses XMLDocument, I'm halfway through but I'm getting error with forEach and I would like to ask for help from you friends, I'll put the code without any changes of mine and with change Anyone who can help is grateful.

No change:

package net.sf.l2j.gameserver.data.xml;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

import net.sf.l2j.commons.data.xml.IXmlReader;

import net.sf.l2j.gameserver.model.event.BossEvent;
import net.sf.l2j.gameserver.templates.StatsSet;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;

/**
 * @author StinkyMadness
 */
public class BossEventData implements IXmlReader
{
   private static final List<StatsSet> data = new ArrayList<>();
  
   protected BossEventData()
   {
       load();
   }
  
   @Override
   public void load()
   {
       parseFile("./data/xml/BossEvent.xml");
   }
  
   @Override
   public void parseDocument(Document doc, Path path)
   {
      
       forEach(doc, "list", listNode -> forEach(listNode, "Boss", bossNode ->
       {
           final StatsSet set = parseAttributes(bossNode);
           forEach(bossNode, "announce", messageNode -> set.set("announceOnSpawn", parseString(messageNode.getAttributes(), "onSpawn")));
           forEach(bossNode, "spawnLoc", positionNode ->
           {
               final NamedNodeMap attrs = positionNode.getAttributes();
               set.set("posX", parseInteger(attrs, "x"));
               set.set("posY", parseInteger(attrs, "y"));
               set.set("posZ", parseInteger(attrs, "z"));
           });
           forEach(bossNode, "despawn", messageNode -> set.set("despawnTime", parseInteger(messageNode.getAttributes(), "after")));
           forEach(bossNode, "scheduleSpawnTime", spawnTimeNode -> set.set("spawnDateData", parseString(spawnTimeNode.getAttributes(), "val")));
           data.add(set);
       }));
      
       data.forEach(BossEvent::new);
   }
  
   public static BossEventData getInstance()
   {
       return SingletonHolder.INSTANCE;
   }
  
   private static class SingletonHolder
   {
       protected static final BossEventData INSTANCE = new BossEventData();
   }
}

With change:

package net.sf.l2j.gameserver.data.xml;

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

import net.sf.l2j.commons.data.xml.XMLDocument;

import net.sf.l2j.gameserver.events.BossEvent;
import net.sf.l2j.gameserver.templates.StatsSet;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;

/**
 * @author StinkyMadness
 */
public class BossEventData extends XMLDocument
{
   private static final List<StatsSet> data = new ArrayList<>();
  
   protected BossEventData()
   {
       load();
   }
  
   @Override
   public void load()
   {
	   loadDocument("./data/xml/BossEvent.xml");
   }
  
   public void parseDocument(Document doc, Path path)
   {
      
       forEach(doc, "list", listNode -> forEach(listNode, "Boss", bossNode ->
       {
           final StatsSet set = parseAttributes(bossNode);
           forEach(bossNode, "announce", messageNode -> set.set("announceOnSpawn", parseString(messageNode.getAttributes(), "onSpawn")));
           forEach(bossNode, "spawnLoc", positionNode ->
           {
               final NamedNodeMap attrs = positionNode.getAttributes();
               set.set("posX", parseInteger(attrs, "x"));
               set.set("posY", parseInteger(attrs, "y"));
               set.set("posZ", parseInteger(attrs, "z"));
           });
           forEach(bossNode, "despawn", messageNode -> set.set("despawnTime", parseInteger(messageNode.getAttributes(), "after")));
           forEach(bossNode, "scheduleSpawnTime", spawnTimeNode -> set.set("spawnDateData", parseString(spawnTimeNode.getAttributes(), "val")));
           data.add(set);
       }));
      
       data.forEach(BossEvent::new);
   }
  
   public static BossEventData getInstance()
   {
       return SingletonHolder.INSTANCE;
   }
  
   private static class SingletonHolder
   {
       protected static final BossEventData INSTANCE = new BossEventData();
   }

/* (non-Javadoc)
 * @see net.sf.l2j.commons.data.xml.XMLDocument#parseDocument(org.w3c.dom.Document, java.io.File)
 */
@Override
protected void parseDocument(Document doc, File f)
{
	// TODO Auto-generated method stub
	
}
}

Errors after change:

[javac] Compiling 1858 source files to C:\workspace\L2jMega_gameserver2\build\classes
    [javac] C:\workspace\L2jMega_gameserver2\java\net\sf\l2j\gameserver\data\xml\BossEventData.java:37: error: cannot find symbol
    [javac]        forEach(doc, "list", listNode -> forEach(listNode, "Boss", bossNode ->
    [javac]        ^
    [javac]   symbol:   method forEach(Document,String,(listNode)[...]); }))
    [javac]   location: class BossEventData
    [javac] C:\workspace\L2jMega_gameserver2\java\net\sf\l2j\gameserver\data\xml\BossEventData.java:44: error: cannot find symbol
    [javac]                set.set("posX", parseInteger(attrs, "x"));
    [javac]                                ^
    [javac]   symbol:   method parseInteger(NamedNodeMap,String)
    [javac]   location: class BossEventData
    [javac] C:\workspace\L2jMega_gameserver2\java\net\sf\l2j\gameserver\data\xml\BossEventData.java:45: error: cannot find symbol
    [javac]                set.set("posY", parseInteger(attrs, "y"));
    [javac]                                ^
    [javac]   symbol:   method parseInteger(NamedNodeMap,String)
    [javac]   location: class BossEventData
    [javac] C:\workspace\L2jMega_gameserver2\java\net\sf\l2j\gameserver\data\xml\BossEventData.java:46: error: cannot find symbol
    [javac]                set.set("posZ", parseInteger(attrs, "z"));
    [javac]                                ^
    [javac]   symbol:   method parseInteger(NamedNodeMap,String)
    [javac]   location: class BossEventData
    [javac] 4 errors

 

4 answers to this question

Recommended Posts

  • 0
Posted (edited)

on acis changeset 377 XMLDocument has been replaced by the IXMLReader interface , so it means you can get it by beign a customer . dont expect ppl to help you ... pay 10E and get all the updates , it will help you since you will have access to DL all the possible changesets of the current circle ..

 

@Kara` he dont mean .forEach , he means the method forEach of the interface IXMLReader

default void forEach(..., ..., ...)

 

Edited by melron

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • We've added 5% discounts for bulk purchases of Google accounts for orders of 300 or more, and 10% for orders of 500 or more. The discount is applied automatically when you place your order! The discount is indicated in the product title and description for each category.  
    • 🎄 CHRISTMAS EVENT 🎄   ‼️ Information and details: https://forum.l2harbor.com/threads/rozhdestvenskie-xlopoty-christmas-chores.9430/post-171464
    • METATG.ORG Direct Telegram Service Provider A bonus of +7% on every order! *We add 7% more followers than your ordered amount to proactively cover potential drops and guarantee you an honest result." Telegram Followers - Price per 1000 SUBSCRIBERS Subscribers 3 days - $0.10 ~ 8 RUB Subscribers. Daily Completion: 200,000,000 Subscribers 7 days - $0.17 ~ 13.6 RUB Subscribers. Daily Completion: 200,000,000 Subscribers 14 days - $0.20 ~ 16 RUB Subscribers. Daily Completion: 200,000,000 Subscribers 30 days - $0.30 ~ 24 RUB Subscribers. Daily Completion: 200,000,000 Subscribers 60 days - $0.40 ~ 32 RUB Subscribers, 14-day guarantee. Daily Completion: 200,000,000 Subscribers 90 days (Super Fast) - $0.50 ~ 40 RUB Subscribers, 14-day guarantee. Daily Completion: 200,000,000 Subscribers 120 days (Super Fast) - $0.60 ~ 48 RUB Subscribers, 14-day guarantee. Daily Completion: 200,000,000 Subscribers Lifetime (Super Fast) - $0.70 ~ 56 RUB Lifetime Subscribers. 14-day guarantee. Daily Completion: 200,000,000 Telegram Services - Price per 1000 Post Views - $0.06 ~ 5 RUB Reactions - $0.08 ~ 6.5 RUB Bot Starts - $0.10 ~ 8 RUB Bot Starts with referrals - $0.15 ~ 12 RUB DISCOUNTS and CASHBACK for large volumes Direct Supplier. We work from our own accounts with our own software! High execution speed. Multiple payment methods. We work 24/7! Additional discounts are discussed for volumes starting from $1000 per day. SUPPORT 24/7 - TELEGRAM WEBSITE 24/7 - METATG.ORG
    • Added: a brand-new default dashboard template. You can now add multiple game/login server builds. Full support for running both PTS & L2J servers simultaneously, with switching between them. Payment systems: added OmegaPay and Pally (new PayPal-style API). Account history now stores everything: donations, items delivered to characters, referrals, transfers between game accounts, and coin transfers to another master account. Personal Promo Code System: you can create a promo code and assign it to a user or promoter. When donating, a player can enter this promo code to receive bonus coins, and the promo code owner also receives a bonus — all fully configurable in the admin panel.     Look demo site: demo
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock