# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/matthias/NetBeansProjects/core-main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: db.core/nbproject/project.xml --- db.core/nbproject/project.xml +++ db.core/nbproject/project.xml @@ -238,6 +238,7 @@ org.netbeans.modules.edm.editor org.netbeans.modules.etl.editor org.netbeans.modules.db.api.sql.execute + org.netbeans.modules.db.api.sql.history Index: db.core/src/org/netbeans/modules/db/api/sql/history/SQLHistory.java --- db.core/src/org/netbeans/modules/db/api/sql/history/SQLHistory.java +++ db.core/src/org/netbeans/modules/db/api/sql/history/SQLHistory.java @@ -0,0 +1,126 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2014 Sun Microsystems, Inc. + */ +package org.netbeans.modules.db.api.sql.history; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public final class SQLHistory implements Collection { + private final Set backingSet; + + SQLHistory(org.netbeans.modules.db.sql.history.SQLHistory history) { + Set set = new HashSet(); + for(org.netbeans.modules.db.sql.history.SQLHistoryEntry sqe: history) { + set.add(new SQLHistoryEntry(sqe)); + } + backingSet = Collections.unmodifiableSet(set); + } + + @Override + public int size() { + return backingSet.size(); + } + + @Override + public boolean isEmpty() { + return backingSet.isEmpty(); + } + + @Override + public boolean contains(Object o) { + return backingSet.contains(o); + } + + @Override + public Iterator iterator() { + return backingSet.iterator(); + } + + @Override + public Object[] toArray() { + return backingSet.toArray(); + } + + @Override + public T[] toArray(T[] a) { + return backingSet.toArray(a); + } + + @Override + public boolean add(SQLHistoryEntry e) { + return backingSet.add(e); + } + + @Override + public boolean remove(Object o) { + return backingSet.remove(o); + } + + @Override + public boolean containsAll(Collection c) { + return backingSet.containsAll(c); + } + + @Override + public boolean addAll(Collection c) { + return backingSet.addAll(c); + } + + @Override + public boolean removeAll(Collection c) { + return backingSet.removeAll(c); + } + + @Override + public boolean retainAll(Collection c) { + return backingSet.retainAll(c); + } + + @Override + public void clear() { + backingSet.clear(); + } + +} Index: db.core/src/org/netbeans/modules/db/api/sql/history/SQLHistoryEntry.java --- db.core/src/org/netbeans/modules/db/api/sql/history/SQLHistoryEntry.java +++ db.core/src/org/netbeans/modules/db/api/sql/history/SQLHistoryEntry.java @@ -0,0 +1,101 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2014 Sun Microsystems, Inc. + */ +package org.netbeans.modules.db.api.sql.history; + +import java.util.Date; + +public class SQLHistoryEntry { + private final String url; + private final String sql; + private final Date date; + + SQLHistoryEntry(org.netbeans.modules.db.sql.history.SQLHistoryEntry sqe) { + this.url = sqe.getUrl(); + this.sql = sqe.getSql(); + this.date = (Date) sqe.getDate().clone(); + } + + public String getUrl() { + return url; + } + + public String getSql() { + return sql; + } + + public Date getDate() { + return (Date) date.clone(); + } + + @Override + public int hashCode() { + int hash = 7; + hash = 89 * hash + (this.url != null ? this.url.hashCode() : 0); + hash = 89 * hash + (this.sql != null ? this.sql.hashCode() : 0); + hash = 89 * hash + (this.date != null ? this.date.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final SQLHistoryEntry other = (SQLHistoryEntry) obj; + if ((this.url == null) ? (other.url != null) : !this.url.equals(other.url)) { + return false; + } + if ((this.sql == null) ? (other.sql != null) : !this.sql.equals(other.sql)) { + return false; + } + if (this.date != other.date && (this.date == null || + !this.date.equals(other.date))) { + return false; + } + return true; + } + + +} Index: db.core/src/org/netbeans/modules/db/api/sql/history/SQLHistoryManager.java --- db.core/src/org/netbeans/modules/db/api/sql/history/SQLHistoryManager.java +++ db.core/src/org/netbeans/modules/db/api/sql/history/SQLHistoryManager.java @@ -0,0 +1,62 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2014 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2014 Sun Microsystems, Inc. + */ +package org.netbeans.modules.db.api.sql.history; + +public final class SQLHistoryManager { + + private SQLHistoryManager() {} + + public static SQLHistoryManager getInstance() { + return LazyHolder.INSTANCE; + } + + public SQLHistory getHistory() { + return new SQLHistory( + org.netbeans.modules.db.sql.history.SQLHistoryManager + .getInstance().getSQLHistory()); + } + + private static class LazyHolder { + + private static final SQLHistoryManager INSTANCE = new SQLHistoryManager(); + } +}