001: package net.sourceforge.squirrel_sql.plugins.mssql.sql.dbfile;
002:
003: /*
004: * Copyright (C) 2004 Ryan Walberg <generalpf@yahoo.com>
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: */
020:
021: import java.util.ArrayList;
022: import java.util.HashMap;
023:
024: public class DatabaseFileInfo {
025:
026: private String _databaseName;
027: private String _databaseSize;
028: private String _owner;
029: private short _compatibilityLevel;
030: private String _createdDate;
031: private HashMap<String, String> _options;
032: private ArrayList<DatabaseFile> _dataFiles;
033: private ArrayList<Object> _logFiles;
034:
035: /** Creates a new instance of DatabaseFileInfo */
036: public DatabaseFileInfo() {
037: _options = new HashMap<String, String>();
038: _dataFiles = new ArrayList<DatabaseFile>();
039: _logFiles = new ArrayList<Object>();
040: }
041:
042: /**
043: * Getter for property databaseSize.
044: * @return Value of property databaseSize.
045: */
046: public String getDatabaseSize() {
047: return this ._databaseSize;
048: }
049:
050: /**
051: * Setter for property databaseSize.
052: * @param databaseSize New value of property databaseSize.
053: */
054: public void setDatabaseSize(String databaseSize) {
055: this ._databaseSize = databaseSize;
056: }
057:
058: /**
059: * Getter for property owner.
060: * @return Value of property owner.
061: */
062: public String getOwner() {
063: return this ._owner;
064: }
065:
066: /**
067: * Setter for property owner.
068: * @param owner New value of property owner.
069: */
070: public void setOwner(String owner) {
071: this ._owner = owner;
072: }
073:
074: /**
075: * Getter for property compatibilityLevel.
076: * @return Value of property compatibilityLevel.
077: */
078: public short getCompatibilityLevel() {
079: return this ._compatibilityLevel;
080: }
081:
082: /**
083: * Setter for property compatibilityLevel.
084: * @param compatibilityLevel New value of property compatibilityLevel.
085: */
086: public void setCompatibilityLevel(short compatibilityLevel) {
087: this ._compatibilityLevel = compatibilityLevel;
088: }
089:
090: /**
091: * Getter for property createdDate.
092: * @return Value of property createdDate.
093: */
094: public String getCreatedDate() {
095: return this ._createdDate;
096: }
097:
098: /**
099: * Setter for property createdDate.
100: * @param createdDate New value of property createdDate.
101: */
102: public void setCreatedDate(String createdDate) {
103: this ._createdDate = createdDate;
104: }
105:
106: public void setOption(String option, String value) {
107: _options.put(option, value);
108: }
109:
110: public String getOption(String option) {
111: if (_options.containsKey(option))
112: return _options.get(option);
113: else
114: return "";
115: }
116:
117: /**
118: * Getter for property databaseName.
119: * @return Value of property databaseName.
120: */
121: public String getDatabaseName() {
122: return this ._databaseName;
123: }
124:
125: /**
126: * Setter for property databaseName.
127: * @param databaseName New value of property databaseName.
128: */
129: public void setDatabaseName(String databaseName) {
130: this ._databaseName = databaseName;
131: }
132:
133: public Object[] getLogFiles() {
134: return this ._logFiles.toArray();
135: }
136:
137: public Object[] getDataFiles() {
138: return this ._dataFiles.toArray();
139: }
140:
141: public void addLogFile(DatabaseFile file) {
142: _logFiles.add(file);
143: }
144:
145: public void addDataFile(DatabaseFile file) {
146: // not so simple -- we want to keep the filegroups together.
147: for (int i = 0; i < _dataFiles.size(); i++) {
148: DatabaseFile f = _dataFiles.get(i);
149: if (f.getFilegroup().equals(file.getFilegroup())) {
150: // keep scanning until we're either EOL or find a different filegroup.
151: for (int j = i + 1; j < _dataFiles.size(); j++) {
152: f = _dataFiles.get(i);
153: if (!f.getFilegroup().equals(file.getFilegroup())) {
154: // j is the index of the first file in the next filegroup.
155: _dataFiles.add(j, file);
156: return;
157: }
158: }
159: }
160: }
161: // if we're still in this function, just add it at the end.
162: _dataFiles.add(file);
163: }
164: }
|