/plugins/SQL/tags/v_0_98/sql/serverTypes/complex/CodeObjectType.java

# · Java · 177 lines · 74 code · 21 blank · 82 comment · 2 complexity · 7f7a7fa3cbc8e94c6aa7e85a8163e095 MD5 · raw file

  1. /**
  2. * CodeObjectType.java - Sql Plugin
  3. * Copyright (C) 2001 Sergey V. Udaltsov
  4. * svu@users.sourceforge.net
  5. *
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. package sql.serverTypes.complex;
  22. import java.io.*;
  23. import java.sql.*;
  24. import java.util.*;
  25. import org.gjt.sp.util.*;
  26. import sql.*;
  27. import sql.serverTypes.ComplexVFS;
  28. /**
  29. * Description of the Class
  30. *
  31. * @author svu
  32. * @created 12 ??????? 2003 ?.
  33. */
  34. public class CodeObjectType implements ComplexVFS.ObjectType
  35. {
  36. protected String typeString;
  37. protected String statementPurpose4List;
  38. protected String statementPurpose4Text;
  39. /**
  40. * Constructor for the CodeObjectType object
  41. *
  42. * @param typeString Description of Parameter
  43. * @since
  44. */
  45. public CodeObjectType( String typeString )
  46. {
  47. this( typeString, null );
  48. }
  49. /**
  50. *Constructor for the CodeObjectType object
  51. *
  52. * @param typeString Description of Parameter
  53. * @param statementPurpose4List Description of Parameter
  54. */
  55. public CodeObjectType( String typeString, String statementPurpose4List )
  56. {
  57. this( typeString, statementPurpose4List, null );
  58. }
  59. /**
  60. *Constructor for the CodeObjectType object
  61. *
  62. * @param typeString Description of Parameter
  63. * @param statementPurpose4Text Description of Parameter
  64. * @param statementPurpose4List Description of Parameter
  65. */
  66. public CodeObjectType( String typeString, String statementPurpose4List, String statementPurpose4Text )
  67. {
  68. this.typeString = typeString;
  69. this.statementPurpose4List = statementPurpose4List != null ? statementPurpose4List : "selectCodeObjectsInSchema";
  70. this.statementPurpose4Text = statementPurpose4Text != null ? statementPurpose4Text : "selectCodeObjectLines";
  71. }
  72. /**
  73. * Gets the Text attribute of the CodeObjectType object
  74. *
  75. * @param path Description of Parameter
  76. * @param rec Description of Parameter
  77. * @param userName Description of Parameter
  78. * @param objName Description of Parameter
  79. * @return The Text value
  80. */
  81. public String getText( String path,
  82. SqlServerRecord rec,
  83. String userName,
  84. String objName )
  85. {
  86. return rec.getServerType().getObjectCreationPrefix() + getSource( path, rec, userName, objName );
  87. }
  88. /**
  89. * Gets the Text attribute of the CodeObjectType object
  90. *
  91. * @param path Description of Parameter
  92. * @param rec Description of Parameter
  93. * @param userName Description of Parameter
  94. * @param objName Description of Parameter
  95. * @return The Text value
  96. * @since
  97. */
  98. public String getSource( String path,
  99. SqlServerRecord rec,
  100. String userName,
  101. String objName )
  102. {
  103. Connection conn = null;
  104. try
  105. {
  106. conn = rec.allocConnection();
  107. final String text = SqlUtils.loadObjectText( conn,
  108. rec,
  109. statementPurpose4Text,
  110. userName,
  111. objName,
  112. typeString );
  113. return text;
  114. } catch ( SQLException ex )
  115. {
  116. Log.log( Log.ERROR, CodeObjectType.class,
  117. "Error loading object code" );
  118. Log.log( Log.ERROR, CodeObjectType.class,
  119. ex );
  120. } finally
  121. {
  122. rec.releaseConnection( conn );
  123. }
  124. return null;
  125. }
  126. /**
  127. * Gets the StatementPurpose attribute of the CodeObjectType object
  128. *
  129. * @return The StatementPurpose value
  130. * @since
  131. */
  132. public String getStatementPurpose()
  133. {
  134. return statementPurpose4List;
  135. }
  136. /**
  137. * Gets the Parameter attribute of the CodeObjectType object
  138. *
  139. * @return The Parameter value
  140. * @since
  141. */
  142. public Object getParameter()
  143. {
  144. return typeString;
  145. }
  146. /**
  147. * Description of the Method
  148. *
  149. * @return Description of the Returned Value
  150. * @since
  151. */
  152. public boolean showResultSetAfterLoad()
  153. {
  154. return false;
  155. }
  156. }