summaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/postgresql/PG_Object.java
blob: 22c0c039c6196fabfdd4353054044029576d5894 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package postgresql;

import java.lang.*;
import java.sql.*;
import java.util.*;
import postgresql.*;

/**
 * postgresql.PG_Object is a class used to describe unknown types 
 * An unknown type is any type that is unknown by JDBC Standards
 *
 * @version 1.0 15-APR-1997
 * @author <A HREF="mailto:[email protected]">Adrian Hall</A>
 */
public class PG_Object
{
  public String	type;
  public String	value;
  
  /**
   *	Constructor for the PostgreSQL generic object
   *
   * @param type a string describing the type of the object
   * @param value a string representation of the value of the object
   */
  public PG_Object(String type, String value) throws SQLException
  {
    this.type = type;
    this.value = value;
  }
  
  /**
   * This returns true if the object is a 'box'
   */
  public boolean isBox()
  {
    return type.equals("box");
  }
  
  /**
   * This returns a PGbox object, or null if it's not
   * @return PGbox
   */
  public PGbox getBox() throws SQLException
  {
    if(isBox())
      return new PGbox(value);
    return null;
  }
  
  /**
   * This returns true if the object is a 'point'
   */
  public boolean isCircle()
  {
    return type.equals("circle");
  }
  
  /**
   * This returns a PGcircle object, or null if it's not
   * @return PGcircle
   */
  public PGcircle getCircle() throws SQLException
  {
    if(isCircle())
      return new PGcircle(value);
    return null;
  }
  
  /**
   * This returns true if the object is a 'lseg' (line segment)
   */
  public boolean isLseg()
  {
    return type.equals("lseg");
  }
  
  /**
   * This returns a PGlsegobject, or null if it's not
   * @return PGlseg
   */
  public PGlseg getLseg() throws SQLException
  {
    if(isLseg())
      return new PGlseg(value);
    return null;
  }
  
  /**
   * This returns true if the object is a 'path'
   */
  public boolean isPath()
  {
    return type.equals("path");
  }
  
  /**
   * This returns a PGpath object, or null if it's not
   * @return PGpath
   */
  public PGpath getPath() throws SQLException
  {
    if(isPath())
      return new PGpath(value);
    return null;
  }
  
  /**
   * This returns true if the object is a 'point'
   */
  public boolean isPoint()
  {
    return type.equals("point");
  }
  
  /**
   * This returns a PGpoint object, or null if it's not
   * @return PGpoint object
   */
  public PGpoint getPoint() throws SQLException
  {
    if(isPoint())
      return new PGpoint(value);
    return null;
  }
  
  /**
   * This returns true if the object is a 'polygon'
   */
  public boolean isPolygon()
  {
    return type.equals("polygon");
  }
  
  /**
   * This returns a PGpolygon object, or null if it's not
   * @return PGpolygon
   */
  public PGpolygon getPolygon() throws SQLException
  {
    if(isPolygon())
      return new PGpolygon(value);
    return null;
  }
}