Location.java :  » Web-Framework » anvil » anvil » Java Open Source

Java Open Source » Web Framework » anvil 
anvil » anvil » Location.java
/*
 * $Id: Location.java,v 1.3 2002/09/16 08:05:02 jkl Exp $
 *
 * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
 *
 * Use is subject to license terms, as defined in
 * Anvil Sofware License, Version 1.1. See LICENSE 
 * file, or http://njet.org/license-1.1.txt
 */
package anvil;

import java.net.URL;
import java.net.MalformedURLException;

/**
 * class Location
 *
 * @author: Jani Lehtimki
 */
public class Location 
{
 
  private URL _url;
  private int _line = 0;
  private int _column = 0;


  public Location(URL url, int line, int column) 
  {
    _url = url;
    _line = line;
    _column = column;
  }


  public Location(String url, int line, int column) 
  {
    try {
      _url = new URL(url);
    } catch (MalformedURLException e) {
    }
    _line = line;
    _column = column;  
  }


  public Location(URL url, int line) 
  {
    _url = url;
    _line = line;
    _column = 0;
  }


  public Location(String url, int line) 
  {
    try {
      _url = new URL(url);
    } catch (MalformedURLException e) {
    }
    _line = line;
  }


  public Location(URL url) 
  {
    _url = url;
    _line = 0;
    _column = 0;
  }


  public Location(String url) 
  {
    try {
      _url = new URL(url);
    } catch (MalformedURLException e) {
    }
  }

  
  public URL getURL() 
  {
    return _url;
  }


  public int getLine() 
  {
    return _line;
  }


  public int getColumn() 
  {
    return _column;
  }
  
  
  public String toString() {
    StringBuffer buffer = new StringBuffer();
    buffer.append(_url);
    buffer.append(' ');
    if (_line > 0) {
      buffer.append('(');
      buffer.append(_line);
      if (_column > 0) {
        buffer.append(':');
        buffer.append(_column);
      }
      buffer.append(')');
    }
    return buffer.toString();
  }
  
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.