// Path: src/util/src/main/java/org/lilycms/util/ObjectUtils.java
// public class ObjectUtils {
//     public static boolean safeEquals(Object obj1, Object obj2) {
//         if (obj1 == null && obj2 == null)
//             return true;
//         else if (obj1 == null || obj2 == null)
//             return false;
//         else
//             return obj1.equals(obj2);
//     }
// }


import org.lilycms.util.ObjectUtils;
import java.io.Serializable;
// This file was copied from the Apache Cocoon 2.1.x source tree.
// Please keep the original license on this file.
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.lilycms.util.location;




/**
 * A simple immutable and serializable implementation of {@link Location}.
 *
 * @since 2.1.8
 */
public class LocationImpl implements Location, Serializable {

    // Package private: outside this package, use Location.UNKNOWN.
    static final LocationImpl UNKNOWN = new LocationImpl(null, null, -1, -1);

    private final String uri;
    private final int line;
    private final int column;
    private final String description;

    /**
     * Build a location for a given URI, with unknown line and column numbers.
     *
     * @param uri the resource URI
     */
    public LocationImpl(String description, String uri) {
        this(description, uri, -1, -1);
    }

    /**
     * Build a location for a given URI and line and columb numbers.
     *
     * @param uri the resource URI
     * @param line the line number (starts at 1)
     * @param column the column number (starts at 1)
     */
    public LocationImpl(String description, String uri, int line, int column) {
        if (uri == null || uri.length() == 0) {
            this.uri = null;
            this.line = -1;
            this.column = -1;
        } else {
            this.uri = uri;
// Path: src/util/src/main/java/org/lilycms/util/ObjectUtils.java
// public class ObjectUtils {
//     public static boolean safeEquals(Object obj1, Object obj2) {
//         if (obj1 == null && obj2 == null)
//             return true;
//         else if (obj1 == null || obj2 == null)
//             return false;
//         else
//             return obj1.equals(obj2);
//     }
// }


// Path: src/util/src/main/java/org/lilycms/util/location/LocationImpl.java
import org.lilycms.util.ObjectUtils;
import java.io.Serializable;

// This file was copied from the Apache Cocoon 2.1.x source tree.
// Please keep the original license on this file.
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.lilycms.util.location;




/**
 * A simple immutable and serializable implementation of {@link Location}.
 *
 * @since 2.1.8
 */
public class LocationImpl implements Location, Serializable {

    // Package private: outside this package, use Location.UNKNOWN.
    static final LocationImpl UNKNOWN = new LocationImpl(null, null, -1, -1);

    private final String uri;
    private final int line;
    private final int column;
    private final String description;

    /**
     * Build a location for a given URI, with unknown line and column numbers.
     *
     * @param uri the resource URI
     */
    public LocationImpl(String description, String uri) {
        this(description, uri, -1, -1);
    }

    /**
     * Build a location for a given URI and line and columb numbers.
     *
     * @param uri the resource URI
     * @param line the line number (starts at 1)
     * @param column the column number (starts at 1)
     */
    public LocationImpl(String description, String uri, int line, int column) {
        if (uri == null || uri.length() == 0) {
            this.uri = null;
            this.line = -1;
            this.column = -1;
        } else {
            this.uri = uri;
            this.line = line;