<commit_before>//$HeadURL: svn+ssh://ms<EMAIL>@svn.<EMAIL>.org/deegree/base/trunk/resources/eclipse/files_template.xml $
/*----------------------------------------------------------------------------
 This file is part of deegree, http://deegree.org/
 Copyright (C) 2001-2010 by:
 - Department of Geography, University of Bonn -
 and
 - lat/lon GmbH -

 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
 Software Foundation; either version 2.1 of the License, or (at your option)
 any later version.
 This library is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 details.
 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, write to the Free Software Foundation, Inc.,
 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

 Contact information:

 lat/lon GmbH
 Aennchenstr. 19, 53177 Bonn
 Germany
 http://lat-lon.de/

 Department of Geography, University of Bonn
 Prof. Dr. <NAME>
 Postfach 1147, 53001 Bonn
 Germany
 http://www.geographie.uni-bonn.de/deegree/

 e-mail: <EMAIL>
 ----------------------------------------------------------------------------*/
package org.deegree.services.wfs.format.gml;

import java.util.Collection;
import java.util.LinkedHashMap;

import javax.xml.stream.XMLStreamException;

import org.deegree.commons.tom.gml.GMLObject;
import org.deegree.commons.tom.gml.GMLReference;
import org.deegree.gml.feature.GMLForwardReferenceHandler;
import org.deegree.protocol.wfs.getfeature.GetFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Keeps track of referenced {@link GMLObject}s that have to be included in a {@link GetFeature} response.
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author last edited by: $Author: markus $
 * 
 * @version $Revision: $, $Date: $
 */
class XlinkedObjectsHandler implements GMLForwardReferenceHandler {

    private static Logger LOG = LoggerFactory.getLogger( XlinkedObjectsHandler.class );

    private LinkedHashMap<String, GMLReference<?>> uriToRef = new LinkedHashMap<String, GMLReference<?>>();

    private final BufferableXMLStreamWriter xmlStream;

    private final boolean localReferencesPossible;

    private final String remoteXlinkTemplate;

    XlinkedObjectsHandler( BufferableXMLStreamWriter xmlStream, boolean localReferencesPossible, String xlinkTemplate ) {
        this.xmlStream = xmlStream;
        this.localReferencesPossible = localReferencesPossible;
        this.remoteXlinkTemplate = xlinkTemplate;
    }

    @Override
    public String requireObject( GMLReference<?> ref ) {
        String uri = ref.getURI();
        LOG.debug( "Exporting forward reference to object {} which must be included in the output.", uri );
        uriToRef.put( ref.getURI(), ref );
        return ref.getURI();
    }

    @Override
    public String handleReference( GMLReference<?> ref ) {

        String uri = ref.getURI();
        LOG.debug( "Encountered reference to object {}.", uri );
        if ( isNonIdBasedUri( uri ) ) {
            LOG.debug( "Reference to object {} considered non-rewritable.", uri );
            return uri;
        }

        if ( localReferencesPossible ) {
            LOG.debug( "Exporting potential forward reference to object {} which may or may not be exported later.",
                       ref.getId() );
            try {
                xmlStream.activateBuffering();
            } catch ( XMLStreamException e ) {
                throw new RuntimeException( e.getMessage(), e );
            }
            return "{" + ref.getId() + "}";
        }
        LOG.debug( "Exporting reference to object {} as remote reference.", ref.getId() );
        return remoteXlinkTemplate.replace( "{}", ref.getId() );
    }

    private boolean isNonIdBasedUri( String uri ) {
        if ( uri.startsWith( "urn" ) ) {
            return true;
        }
        // hacks for CITE WFS 1.1.0
        if ( uri.startsWith( "http://vancouver1.demo.galdosinc.com" ) ) {
            return true;
        }
        if ( uri.startsWith( "ftp://vancouver1.demo.galdosinc.com" ) ) {
            return true;
        }
        return false;
    }

    Collection<GMLReference<?>> getAdditionalRefs() {
        return uriToRef.values();
    }

    void clear() {
        uriToRef = new LinkedHashMap<String, GMLReference<?>>();
    }
}
<commit_msg>Removed method call in requireObject method by using local field uri instead.<commit_after>//$HeadURL: svn+ssh://mschneider@svn.wald.intevation.org/deegree/base/trunk/resources/eclipse/files_template.xml $
/*----------------------------------------------------------------------------
 This file is part of deegree, http://deegree.org/
 Copyright (C) 2001-2010 by:
 - Department of Geography, University of Bonn -
 and
 - lat/lon GmbH -

 This library is free software; you can redistribute it and/or modify it under
 the terms of the GNU Lesser General Public License as published by the Free
 Software Foundation; either version 2.1 of the License, or (at your option)
 any later version.
 This library is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 details.
 You should have received a copy of the GNU Lesser General Public License
 along with this library; if not, write to the Free Software Foundation, Inc.,
 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

 Contact information:

 lat/lon GmbH
 Aennchenstr. 19, 53177 Bonn
 Germany
 http://lat-lon.de/

 Department of Geography, University of Bonn
 Prof. Dr. <NAME>
 Postfach 1147, 53001 Bonn
 Germany
 http://www.geographie.uni-bonn.de/deegree/

 e-mail: <EMAIL>
 ----------------------------------------------------------------------------*/
package org.deegree.services.wfs.format.gml;

import java.util.Collection;
import java.util.LinkedHashMap;

import javax.xml.stream.XMLStreamException;

import org.deegree.commons.tom.gml.GMLObject;
import org.deegree.commons.tom.gml.GMLReference;
import org.deegree.gml.feature.GMLForwardReferenceHandler;
import org.deegree.protocol.wfs.getfeature.GetFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Keeps track of referenced {@link GMLObject}s that have to be included in a {@link GetFeature} response.
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author last edited by: $Author: markus $
 * 
 * @version $Revision: $, $Date: $
 */
class XlinkedObjectsHandler implements GMLForwardReferenceHandler {

    private static Logger LOG = LoggerFactory.getLogger( XlinkedObjectsHandler.class );

    private LinkedHashMap<String, GMLReference<?>> uriToRef = new LinkedHashMap<String, GMLReference<?>>();

    private final BufferableXMLStreamWriter xmlStream;

    private final boolean localReferencesPossible;

    private final String remoteXlinkTemplate;

    XlinkedObjectsHandler( BufferableXMLStreamWriter xmlStream, boolean localReferencesPossible, String xlinkTemplate ) {
        this.xmlStream = xmlStream;
        this.localReferencesPossible = localReferencesPossible;
        this.remoteXlinkTemplate = xlinkTemplate;
    }

    @Override
    public String requireObject( GMLReference<?> ref ) {
        String uri = ref.getURI();
        LOG.debug( "Exporting forward reference to object {} which must be included in the output.", uri );
        uriToRef.put( uri, ref );
        return uri;
    }

    @Override
    public String handleReference( GMLReference<?> ref ) {

        String uri = ref.getURI();
        LOG.debug( "Encountered reference to object {}.", uri );
        if ( isNonIdBasedUri( uri ) ) {
            LOG.debug( "Reference to object {} considered non-rewritable.", uri );
            return uri;
        }

        if ( localReferencesPossible ) {
            LOG.debug( "Exporting potential forward reference to object {} which may or may not be exported later.",
                       ref.getId() );
            try {
                xmlStream.activateBuffering();
            } catch ( XMLStreamException e ) {
                throw new RuntimeException( e.getMessage(), e );
            }
            return "{" + ref.getId() + "}";
        }
        LOG.debug( "Exporting reference to object {} as remote reference.", ref.getId() );
        return remoteXlinkTemplate.replace( "{}", ref.getId() );
    }

    private boolean isNonIdBasedUri( String uri ) {
        if ( uri.startsWith( "urn" ) ) {
            return true;
        }
        // hacks for CITE WFS 1.1.0
        if ( uri.startsWith( "http://vancouver1.demo.galdosinc.com" ) ) {
            return true;
        }
        if ( uri.startsWith( "ftp://vancouver1.demo.galdosinc.com" ) ) {
            return true;
        }
        return false;
    }

    Collection<GMLReference<?>> getAdditionalRefs() {
        return uriToRef.values();
    }

    void clear() {
        uriToRef = new LinkedHashMap<String, GMLReference<?>>();
    }
}

{'fraction_non_alphanumeric': 0.1297355639503508, 'fraction_numerical': 0.010145709660010794, 'mean_word_length': 2.6026438569206842, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 14}, 'pii_count': 1, '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': '5223164', 'n_tokens_mistral': 2637, 'n_tokens_neox': 2511, 'n_words': 789}