001// Copyright 2007 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry5.commons.internal.services;
016
017import org.apache.tapestry5.commons.Location;
018import org.apache.tapestry5.commons.Resource;
019
020/**
021 * Implementation of {@link Location} used when the underlying resource isn't really known.
022 */
023public final class StringLocation implements Location
024{
025    private final String description;
026
027    private final int line;
028
029    public StringLocation(String description, int line)
030    {
031        this.description = description;
032        this.line = line;
033    }
034
035    @Override
036    public String toString()
037    {
038        return description;
039    }
040
041    /**
042     * Returns 0.
043     */
044    @Override
045    public int getColumn()
046    {
047        return 0;
048    }
049
050    @Override
051    public int getLine()
052    {
053        return line;
054    }
055
056    /**
057     * Returns null; we don't know where the file really is (it's probably a class on the class path).
058     */
059    @Override
060    public Resource getResource()
061    {
062        return null;
063    }
064
065}