<commit_before>package ch.openech.xml.write;

import static ch.openech.model.XmlConstants.*;

import java.util.List;

import org.minimalj.util.StringUtils;

import ch.openech.model.common.NamedId;
import ch.openech.model.contact.Contact;
import ch.openech.model.contact.ContactEntry;

public class WriterEch0046 extends DeliveryWriter {

	public final String URI;
	public final WriterEch0010 ech10;
	public final WriterEch0044 ech44;
	
	public WriterEch0046(EchSchema context) {
		super(context);
		URI = context.getNamespaceURI(46);
		ech10 = new WriterEch0010(context);
		ech44 = new WriterEch0044(context);
	}
	
	@Override
	protected int getSchemaNumber() {
		return 46;
	}
	
	@Override
	protected String getNamespaceURI() {
		return URI;
	}

	@Override
	protected String getRootType() {
		return CONTACT_ROOT;
	}

	public String contactRoot(Contact contact) throws Exception {
		WriterElement contactRoot = delivery();
		contact(contactRoot, contact);
		return result();
	}

	public void contact(WriterElement parent, Contact contact) throws Exception {
		contact(parent, CONTACT, contact);
	}
	
	public void contact(WriterElement element, List<ContactEntry> contacts) throws Exception {
		Contact contact = new Contact();
		contact.entries.addAll(contacts);
		contact(element, CONTACT, contact);
	}
	
	public void contact(WriterElement parent, String tagName, Contact contact) throws Exception {
		if (contact == null) return;
		
		WriterElement contactElement = parent.create(URI, tagName);
		localID(contactElement, contact.stringId);
		for (ContactEntry entry : contact.getAddressList()) address(contactElement, entry);
		for (ContactEntry entry : contact.getEmailList()) email(contactElement, entry);
		for (ContactEntry entry : contact.getPhoneList()) phone(contactElement, entry);
		for (ContactEntry entry : contact.getInternetList()) internet(contactElement, entry);
	}
	
	private void localID(WriterElement parent, String id) throws Exception {
		if (id == null) return;
		NamedId namedPersonId = new NamedId();
		namedPersonId.personIdCategory = "CH.OPENECH";
		namedPersonId.personId = id;
		ech44.namedId(parent, namedPersonId, LOCAL_I_D);
	}<commit_msg>WriterEch0046: vorhandene String Konstante verwenden<commit_after>package ch.openech.xml.write;

import static ch.openech.model.XmlConstants.*;

import java.util.List;

import org.minimalj.util.StringUtils;

import ch.openech.model.common.NamedId;
import ch.openech.model.contact.Contact;
import ch.openech.model.contact.ContactEntry;

public class WriterEch0046 extends DeliveryWriter {

	public final String URI;
	public final WriterEch0010 ech10;
	public final WriterEch0044 ech44;
	
	public WriterEch0046(EchSchema context) {
		super(context);
		URI = context.getNamespaceURI(46);
		ech10 = new WriterEch0010(context);
		ech44 = new WriterEch0044(context);
	}
	
	@Override
	protected int getSchemaNumber() {
		return 46;
	}
	
	@Override
	protected String getNamespaceURI() {
		return URI;
	}

	@Override
	protected String getRootType() {
		return CONTACT_ROOT;
	}

	public String contactRoot(Contact contact) throws Exception {
		WriterElement contactRoot = delivery();
		contact(contactRoot, contact);
		return result();
	}

	public void contact(WriterElement parent, Contact contact) throws Exception {
		contact(parent, CONTACT, contact);
	}
	
	public void contact(WriterElement element, List<ContactEntry> contacts) throws Exception {
		Contact contact = new Contact();
		contact.entries.addAll(contacts);
		contact(element, CONTACT, contact);
	}
	
	public void contact(WriterElement parent, String tagName, Contact contact) throws Exception {
		if (contact == null) return;
		
		WriterElement contactElement = parent.create(URI, tagName);
		localID(contactElement, contact.stringId);
		for (ContactEntry entry : contact.getAddressList()) address(contactElement, entry);
		for (ContactEntry entry : contact.getEmailList()) email(contactElement, entry);
		for (ContactEntry entry : contact.getPhoneList()) phone(contactElement, entry);
		for (ContactEntry entry : contact.getInternetList()) internet(contactElement, entry);
	}
	
	private void localID(WriterElement parent, String id) throws Exception {
		if (id == null) return;
		NamedId namedPersonId = new NamedId();
		namedPersonId.personIdCategory = NamedId.OPEN_ECH_ID_CATEGORY;
		namedPersonId.personId = id;
		ech44.namedId(parent, namedPersonId, LOCAL_I_D);
	}
{'fraction_non_alphanumeric': 0.09711166704571299, 'fraction_numerical': 0.018194223334091427, 'mean_word_length': 5.439238653001464, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5007703', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1293, 'n_words': 342}