if (forSale) {
try {
int begin = 0;
int end = 0;
ItemLine itemLine = new ItemLine();
itemLine.setItem(new Item());
itemLine.setForSale(true);
begin = 0;
end = row.indexOf("X ", begin);
if (Character.isDigit(row.charAt(end + 2))) {
//the X of the price
itemLine.getItem().setName(row.substring(begin, end).replace('*', ' ').trim());
} else {
//next X
end = row.indexOf("X ", end + 1);
itemLine.getItem().setName(row.substring(begin, end).replace('*', ' ').trim());
}
begin = end + 2;
end = row.indexOf(" (", begin);
String qty = row.substring(begin, end).trim();
itemLine.setQuantity(Long.parseLong(qty));
begin = end + 2;
end = row.indexOf("Isaton");
String weight = row.substring(begin, end).trim();
long w = Long.parseLong(weight);
weightCache.put(itemLine.getItem().getName(), new Long(w));
itemLine.getItem().setWeight(w);
begin = row.indexOf("for $") + 5;
end = row.indexOf(" ", begin);
itemLine.setPrice(Long.parseLong(row.substring(begin, end).trim()));
Location l = new Location();
begin = end + 1;
l.setName(row.substring(begin).replace('*', ' ').trim());
if (planet) {
l.setPlanet(true);
l.setSystem(cursys);
}
if (starbase) {
l.setPlanet(false);
l.setSystem(cursys);
}
// JUST a sec, lets check the coord cache.
LocationProperty lp = locationsProperties.get(itemLine.getItem().getName());
if (lp != null) {
l.setSector(lp.getSector());
l.setGrid(lp.getGrid());
}
itemLine.setLocation(l);
curpl.getForSale().add(itemLine);
} catch (Exception ex) {
throw new Exception("Impossible to import the pricelist. Offending line: " + row, ex);
}
}
if (wanted) {
try {
int begin = 0;
int end = 0;
ItemLine itemLine = new ItemLine();
itemLine.setItem(new Item());
itemLine.setForSale(false);
begin = 0;
end = row.indexOf("X ", begin);
if (Character.isDigit(row.charAt(end + 2))) {
//the X of the price