<commit_before>/*
 * Copyright 2001-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.ws.scout.registry.infomodel;

import javax.xml.registry.JAXRException;
import javax.xml.registry.LifeCycleManager;
import javax.xml.registry.UnsupportedCapabilityException;
import javax.xml.registry.infomodel.Association;
import javax.xml.registry.infomodel.Classification;
import javax.xml.registry.infomodel.Concept;
import javax.xml.registry.infomodel.ExternalIdentifier;
import javax.xml.registry.infomodel.ExternalLink;
import javax.xml.registry.infomodel.InternationalString;
import javax.xml.registry.infomodel.Key;
import javax.xml.registry.infomodel.Organization;
import javax.xml.registry.infomodel.RegistryObject;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * Implements  RegistryObject Interface
 * Implements JAXR Interface.
 * For futher details, look into the JAXR API Javadoc.
 *
 * @author <NAME>  <<EMAIL>>
 */
public class RegistryObjectImpl extends ExtensibleObjectImpl implements RegistryObject
{
    private final LifeCycleManager lifeCycleManager;
    private Key key;
    private InternationalString name = new InternationalStringImpl();
    private InternationalString desc = new InternationalStringImpl();

    private Set classifications = new HashSet();
    private Set associations = new HashSet();
    private Set externalIds = new HashSet();
    private Set externalLinks = new HashSet();

    private OrganizationImpl submittingOrganization;

    public RegistryObjectImpl(LifeCycleManager lifeCycleManager)
    {
        this.lifeCycleManager = lifeCycleManager;
    }

    public RegistryObjectImpl(LifeCycleManager lifeCycleManager, InternationalString n)
    {
        this.lifeCycleManager = lifeCycleManager;
        name = n;
    }

    public Key getKey()
    {
        return key;
    }

    public InternationalString getDescription()
    {
        return desc;
    }

    public void setDescription(InternationalString description)
    {
        this.desc = description;
    }

    public InternationalString getName()
    {
        return name;
    }

    public void setName(InternationalString name)
    {
        this.name = name;
    }

    public void setKey(Key k)
    {
        key = k;
    }

    public String toXML() throws JAXRException
    {
        throw new UnsupportedCapabilityException("toXML is not supported");
    }

    public void addClassification(Classification classification)
    {
        classifications.add(classification);
    }

    public void addClassifications(Collection collection)
    {
        for (Iterator i = collection.iterator(); i.hasNext();)
        {
            Classification classification = (Classification) i.next();
            classifications.add(classification);
        }
    }

    public void removeClassification(Classification classification)
    {
        classifications.remove(classification);
    }

    public void removeClassifications(Collection collection)
    {
        classifications.removeAll(collection);
    }

    public Collection getClassifications()
    {
        return Collections.unmodifiableSet(classifications);
    }

    public void setClassifications(Collection collection)
    {
        Set newClassifications = new HashSet(collection.size());
        for (Iterator i = collection.iterator(); i.hasNext();)
        {
            Classification classification = (Classification) i.next();
            newClassifications.add(classification);
        }
        classifications = newClassifications;
    }

    public void addAssociation(Association association)
    {
        associations.add(association);
    }

    public void addAssociations(Collection collection) throws JAXRException
    {
        for (Iterator i = collection.iterator(); i.hasNext();)
        {
            Association association = (Association) i.next();
            associations.add(association);
        }
    }

    public Collection getAssociations() throws JAXRException
    {
        return Collections.unmodifiableSet(associations);
    }

    public void setAssociations(Collection collection)
    {
        Set newAssociations = new HashSet(collection.size());
        for (Iterator i = collection.iterator(); i.hasNext();)
        {
            Association association = (Association) i.next();
            newAssociations.add(association);
        }
        associations = newAssociations;
    }

    public void removeAssociation(Association association)
    {
        associations.remove(association);
    }
<commit_msg>We're supposed to change the source object for an association when an association is set on the source...<commit_after>/*
 * Copyright 2001-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.ws.scout.registry.infomodel;

import javax.xml.registry.JAXRException;
import javax.xml.registry.LifeCycleManager;
import javax.xml.registry.UnsupportedCapabilityException;
import javax.xml.registry.infomodel.Association;
import javax.xml.registry.infomodel.Classification;
import javax.xml.registry.infomodel.Concept;
import javax.xml.registry.infomodel.ExternalIdentifier;
import javax.xml.registry.infomodel.ExternalLink;
import javax.xml.registry.infomodel.InternationalString;
import javax.xml.registry.infomodel.Key;
import javax.xml.registry.infomodel.Organization;
import javax.xml.registry.infomodel.RegistryObject;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * Implements  RegistryObject Interface
 * Implements JAXR Interface.
 * For futher details, look into the JAXR API Javadoc.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author <a href="mailto:<EMAIL>"><NAME>.</a>
 */
public class RegistryObjectImpl extends ExtensibleObjectImpl implements RegistryObject
{
    private final LifeCycleManager lifeCycleManager;
    private Key key;
    private InternationalString name = new InternationalStringImpl();
    private InternationalString desc = new InternationalStringImpl();

    private Set classifications = new HashSet();
    private Set associations = new HashSet();
    private Set externalIds = new HashSet();
    private Set externalLinks = new HashSet();

    private OrganizationImpl submittingOrganization;

    public RegistryObjectImpl(LifeCycleManager lifeCycleManager)
    {
        this.lifeCycleManager = lifeCycleManager;
    }

    public RegistryObjectImpl(LifeCycleManager lifeCycleManager, InternationalString n)
    {
        this.lifeCycleManager = lifeCycleManager;
        name = n;
    }

    public Key getKey()
    {
        return key;
    }

    public InternationalString getDescription()
    {
        return desc;
    }

    public void setDescription(InternationalString description)
    {
        this.desc = description;
    }

    public InternationalString getName()
    {
        return name;
    }

    public void setName(InternationalString name)
    {
        this.name = name;
    }

    public void setKey(Key k)
    {
        key = k;
    }

    public String toXML() throws JAXRException
    {
        throw new UnsupportedCapabilityException("toXML is not supported");
    }

    public void addClassification(Classification classification)
    {
        classifications.add(classification);
    }

    public void addClassifications(Collection collection)
    {
        for (Iterator i = collection.iterator(); i.hasNext();)
        {
            Classification classification = (Classification) i.next();
            classifications.add(classification);
        }
    }

    public void removeClassification(Classification classification)
    {
        classifications.remove(classification);
    }

    public void removeClassifications(Collection collection)
    {
        classifications.removeAll(collection);
    }

    public Collection getClassifications()
    {
        return Collections.unmodifiableSet(classifications);
    }

    public void setClassifications(Collection collection)
    {
        Set newClassifications = new HashSet(collection.size());
        for (Iterator i = collection.iterator(); i.hasNext();)
        {
            Classification classification = (Classification) i.next();
            newClassifications.add(classification);
        }
        classifications = newClassifications;
    }

    /**
     *  Adds specified Association to use this object as source.
     *  Silently replaces the sourceObject in Association with
     *  reference to this object.
     *
     * @param association
     * @throws JAXRException
     */
    public void addAssociation(Association association)
        throws JAXRException
    {
        associations.add(association);

        association.setSourceObject(this);
    }

    public void addAssociations(Collection collection) throws JAXRException
    {
        for (Iterator i = collection.iterator(); i.hasNext();)
        {
            Association association = (Association) i.next();

            addAssociation(association);
        }
    }

    public Collection getAssociations() throws JAXRException
    {
        return Collections.unmodifiableSet(associations);
    }

    public void setAssociations(Collection collection)
    {
        Set newAssociations = new HashSet(collection.size());
        for (Iterator i = collection.iterator(); i.hasNext();)
        {
            Association association = (Association) i.next();
            newAssociations.add(association);
        }
        associations = newAssociations;
    }

    public void removeAssociation(Association association)
    {
        associations.remove(association);
    }

{'fraction_non_alphanumeric': 0.08141250230499723, 'fraction_numerical': 0.0022127973446431862, 'mean_word_length': 3.1543469934890846, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 24}, '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': '3637669', 'n_tokens_mistral': 2847, 'n_tokens_neox': 2711, 'n_words': 749}