TurtleDB
A mini distributed database system
src/ca/uqac/dim/turtledb/Schema.java
Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002     Simple distributed database engine
00003     Copyright (C) 2012  Sylvain Hallé
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017  -------------------------------------------------------------------------*/
00018 package ca.uqac.dim.turtledb;
00019 
00020 import java.util.Vector;
00021 
00027 public class Schema extends Vector<Attribute>
00028 {
00029 
00033   private static final long serialVersionUID = 1L;
00034   
00038   public Schema()
00039   {
00040     super();
00041   }
00042   
00047   public Schema(String s)
00048   {
00049     this();
00050     String parts[] = s.split(",");
00051     for (String a : parts)
00052     {
00053       a = a.trim();
00054       Attribute att = new Attribute(a);
00055       this.add(att);
00056     }
00057   }
00058   
00063   public Schema(Schema s)
00064   {
00065     this();
00066     for (Attribute att : s)
00067     {
00068       this.add(att);
00069     }
00070   }
00071   
00077   public Schema(String tableName, String s)
00078   {
00079     String parts[] = s.split(",");
00080     for (String a : parts)
00081     {
00082       a = a.trim();
00083       Attribute att = new Attribute(a);
00084       att.setTableName(tableName);
00085       this.add(att);
00086     }
00087   }
00088   
00095   protected void createFromString(String s)
00096   {
00097     String parts[] = s.split(",");
00098     for (String a : parts)
00099     {
00100       a = a.trim();
00101       Attribute att = new Attribute(a);
00102       this.add(att);
00103     }    
00104   }
00105   
00110   public void setTableName(String name)
00111   {
00112           for (Attribute a : this)
00113                   a.setTableName(name);
00114   }
00115 
00116 }