Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package net.sourceforge.squirrel_sql.plugins.favs;
   * Copyright (C) 2001 Colin Bell
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version 2
   * of the License, or any later version.
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * GNU General Public License for more details.
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
This class represents a query that can be saved and restored.
 final class Query implements CloneableSerializableIHasIdentifierIValidatable {
     private static final long serialVersionUID = 1L;
     private static final String EMPTY_STRING = "";
 	public interface IPropertyNames {
 		String DESCRIPTION = "Description";
 		String ID = "Identifier";
 		String NAME = "Name";
 		String SQL = "Sql";
The IIdentifier that uniquely identifies this object.
 	private IIdentifier _id;

 	private String _name;

Description for this query.
 	private String _description;

 	private String _sql;

Default ctor.
 	public Query() {
 		this(IdentifierFactory.getInstance().createIdentifier(), ,

Ctor specifying this objects attributes.

id Uniquely identifies this object.
name Name of thi query.
description The description of this alias.
sql The SQL to execute.
 	public Query(IIdentifier idString nameString descriptionString sql) {
 		 = id != null ? id : IdentifierFactory.getInstance().createIdentifier();
 		 = getString(name);
 		 = getString(description);
 		 = getString(sql);

Two Query objects are considered equal if their ID's are identical unless their ID's are

true if this object is equal to the passed one.
 	public boolean equals(Object rhs) {
 		boolean rc = false;
 		if (rhs != null && rhs.getClass().equals(getClass())) {
 			rc = ((Query)rhs).getIdentifier().equals(getIdentifier());
 		return rc;

Return a copy of this object.
 	public Object clone() {
 		try {
 			return super.clone();
			throw new InternalError(ex.getMessage());   // Impossible.
	public synchronized int hashCode() {
	public String toString() {
		return getName();

Returns true if this object is valid.

Implementation for IPersistable.

	public synchronized boolean isValid() {
		return .trim().length() > 0 && .trim().length() > 0;
		return ;
	public String getName() {
		return ;
	private String getString(String data) {
		return data != null ? data.trim() : "";
New to GrepCode? Check out our FAQ X