private static void addName(Map<String, String> idMapping, Set<String> names, cim1.model.IdentifiedObject object) { StringBuilder name = new StringBuilder(); if (object instanceof cim1.model.PowerTransformer) { // name field seems to always contains "1" while description seems to have a name constistent with // lines one. Just reshape it to look like lines Matcher matcher = POWER_TRANSFORMER_DESCRIPTION_PATTERN.matcher(object.getDescription()); if (matcher.matches()) { name.append(matcher.group(1)).append("_").append(matcher.group(2)).append("_").append(matcher.group(3)).append("_").append(matcher.group(4)); } } else { name.append(object.getName().trim()); // generators and loads have the same naming and collides, just add to suffixe to distinguish generators // and loads if (object instanceof SynchronousMachine) { name.append("_GEN"); } else if (object instanceof EnergyConsumer) { name.append("_LOAD"); } } if (name.toString().isEmpty()) { throw new CIM1Exception(object.getId() + " is unnamed"); } if (names.contains(name.toString())) { throw new CIM1Exception(object.getId() + " name is not unique: " + name); } names.add(name.toString()); idMapping.put(object.getId(), name.toString()); }
xmlsw.writeCharacters(getDescription()); xmlsw.writeEndElement();
newdescription = otherIdentifiedObject.getDescription(); this.setDescription(newdescription);