コード例 #1
0
 internal static String[] getPortForwarding(Session session)
 {
     java.util.Vector foo = new java.util.Vector();
     lock (pool)
     {
         for (int i = 0; i < pool.size(); i++)
         {
             Object[] bar = (Object[])(pool.elementAt(i));
             if (bar[0] != session)
             {
                 continue;
             }
             if (bar[3] == null)
             {
                 foo.addElement(bar[1] + ":" + bar[2] + ":");
             }
             else
             {
                 foo.addElement(bar[1] + ":" + bar[2] + ":" + bar[3]);
             }
         }
     }
     String[] bar2 = new String[foo.size()];
     for (int i = 0; i < foo.size(); i++)
     {
         bar2[i] = (String)(foo.elementAt(i));
     }
     return(bar2);
 }
コード例 #2
0
        /**
         *
         * Insert a row. If c or v == null, insert a blank row
         *
         * @param c Ordered Vector of column names
         * @param v Ordered Vector (must match order of c) of values
         * @see tinySQLTable#InsertRow()
         *
         */
        public override void InsertRow(java.util.Vector <Object> c, java.util.Vector <Object> v)
        {// throws tinySQLException {
            try
            {
                // go to the end of the file
                //
                ftbl.seek(ftbl.length());

                // write out the deleted indicator
                //
                ftbl.write('N');

                // write out a blank record
                //
                for (int i = 1; i < record_length; i++)
                {
                    ftbl.write(' ');
                }
                ftbl.write('\n');

                // reposition at start of current record
                //
                ftbl.seek(ftbl.getFilePointer() - (record_length + 1));
            }
            catch (Exception e)
            {
                throw new TinySQLException(e.getMessage());
            }

            if (c != null && v != null)
            {
                UpdateCurrentRow(c, v);
            }
        }
コード例 #3
0
        internal override void CreateTable(String tableName, java.util.Vector <Object> v)
        {//    throws IOException, tinySQLException {
            //---------------------------------------------------
            // determin meta data ....
            int numCols      = v.size();
            int recordLength = 1;        // 1 byte for the flag field

            for (int i = 0; i < numCols; i++)
            {
                TsColumn coldef = ((TsColumn)v.elementAt(i));
                recordLength += coldef.size;
            }

            //---------------------------------------------------
            // create the new dBase file ...
            DBFHeader dbfHeader = new DBFHeader(numCols, recordLength);

            java.io.RandomAccessFile ftbl = dbfHeader.create(dataDir, tableName);

            //---------------------------------------------------
            // write out the rest of the columns' definition.
            for (int i = 0; i < v.size(); i++)
            {
                TsColumn coldef = ((TsColumn)v.elementAt(i));
                Utils.log("CREATING COL=" + coldef.name);
                writeColdef(ftbl, coldef);
            }

            ftbl.write((byte)0x0d); // header section ends with CR (carriage return)

            ftbl.close();
        }
コード例 #4
0
        /**
         *
         * Constructs a new tinySQLStatement object.
         * @param conn the tinySQLConnection object
         *
         */
        public TinySQLPreparedStatement(TinySQLConnection conn, String inputString)
        {
            int nextQuestionMark, startAt;

            connection      = conn;
            startAt         = 0;
            statementString = inputString;
            while ((nextQuestionMark = statementString.indexOf("?", startAt)) > -1)
            {
                if (substitute == (java.util.Vector <Object>)null)
                {
                    substitute = new java.util.Vector <Object>();
                }
                substitute.addElement("");
                startAt = nextQuestionMark + 1;
            }
            invalidIndex = " is not in the range 1 to "
                           + java.lang.Integer.toString(substitute.size());
            if (debug)
            {
                java.lang.SystemJ.outJ.println("Prepare statement has " + substitute.size()
                                               + " parameters.");
            }

            this.setPoolable(true); //Basties note: see Java documentation java.sql.SQLStatement.isPoolable
        }
コード例 #5
0
        /*
         * Scan the given directory for files containing the substrMatch<br>
         * Small case extensions '.dbf' are recognized and returned as '.DBF'
         */
        public static java.util.Vector <Object> getAllFiles(String path, String suffix)
        {
            java.util.Vector <Object> vec = null;
            String[]     fileNameList;
            java.io.File currentDir, f;
            String       fileName, upperSuffix;
            int          i;

            upperSuffix  = suffix.toUpperCase();
            currentDir   = new java.io.File(path);
            fileNameList = currentDir.list();
            if (fileNameList == null)
            {
                java.lang.SystemJ.outJ.println("*** null for " + path);
            }
            else
            {
                vec = new java.util.Vector <Object>(fileNameList.Length);
                for (i = 0; i < fileNameList.Length; i++)
                {
                    f = new java.io.File(fileNameList[i]);
                    if (!f.isDirectory())
                    {
                        fileName = f.getPath().toString().toUpperCase();
                        //           lastModified = new java.util.Date(f.lastModified());
                        if (upperSuffix == null | fileName.endsWith(upperSuffix))
                        {
                            vec.addElement(f);
                        }
                    }
                }
            }
            return(vec);
        }
コード例 #6
0
ファイル: DriverManager.cs プロジェクト: bastie/NetVampire
        /**
         * Returns an {@code Enumeration} that contains all of the loaded JDBC
         * drivers that the current caller can access.
         *
         * @return An {@code Enumeration} containing all the currently loaded JDBC
         *         {@code Drivers}.
         */
        public static java.util.Enumeration <Driver> getDrivers()
        {
            java.lang.ClassLoader callerClassLoader = java.lang.Runtime.getRuntime().getClass().getClassLoader();// Basties note: sometime do the same as VM.callerClassLoader();

            /*
             * Synchronize to avoid clashes with additions and removals of drivers
             * in the DriverSet
             */
            lock (theDrivers)
            {
                /*
                 * Create the Enumeration by building a Vector from the elements of
                 * the DriverSet
                 */
                java.util.Vector <Driver>   theVector   = new java.util.Vector <Driver>();
                java.util.Iterator <Driver> theIterator = theDrivers.iterator();
                while (theIterator.hasNext())
                {
                    Driver theDriver = theIterator.next();
                    if (DriverManager.isClassFromClassLoader(theDriver,
                                                             callerClassLoader))
                    {
                        theVector.add(theDriver);
                    }
                }
                return(theVector.elements());
            }
        }
コード例 #7
0
        /*
         * Find the input table alias in the list provided and return the table name.
         */
        public static String findTableForAlias(String inputAlias, java.util.Vector <Object> tableList)
        //throws tinySQLException
        {
            int    aliasAt;
            String tableAndAlias;

            tableAndAlias = findTableAlias(inputAlias, tableList);
            aliasAt       = tableAndAlias.indexOf("->");
            return(tableAndAlias.substring(0, aliasAt));
        }
コード例 #8
0
 /**
  * Constructs a new {@code SequenceInputStream} using the two streams
  * {@code s1} and {@code s2} as the sequence of streams to read from.
  *
  * @param s1
  *            the first stream to get bytes from.
  * @param s2
  *            the second stream to get bytes from.
  * @throws NullPointerException
  *             if {@code s1} is {@code null}.
  */
 public SequenceInputStream(InputStream s1, InputStream s2)
 {
     if (s1 == null) {
         throw new java.lang.NullPointerException ();
     }
     java.util.Vector<InputStream> inVector = new java.util.Vector<InputStream> (1);
     inVector.addElement (s2);
     e = inVector.elements ();
     inJ = s1;
 }
コード例 #9
0
        /*
         * Update rows which match a WHERE clause
         */
        private void UpdateStatement(String tableName, java.util.Vector <Object> c, java.util.Vector <Object> v, TinySQLWhere wc)
        //throws TinySQLException
        {
            /*
             *    Create a table object and put it in the Hashtable.
             */
            TinySQLTable jtbl = getTable(tableName);

            java.util.Hashtable <Object, Object> tables = new java.util.Hashtable <Object, Object>();
            tables.put(tableName, jtbl);
            String columnName, columnString, whereStatus;

            /*
             *    Process each row in the table ignoring deleted rows.
             */
            jtbl.GoTop();
            while (jtbl.NextRecord())
            {
                if (!jtbl.isDeleted())
                {
                    java.util.Enumeration <Object> cols = jtbl.column_info.keys();
                    whereStatus = "TRUE";
                    while (cols.hasMoreElements())
                    {
                        /*
                         *             Use the table name for the table alias for updates.
                         */
                        columnName = jtbl.table + "->" + jtbl.table
                                     + "." + (String)cols.nextElement();
                        columnString = jtbl.GetCol(columnName);

                        /*
                         *             Check the status of the where clause for each column value.
                         */
                        if (wc != (TinySQLWhere)null)
                        {
                            whereStatus = wc.evaluate(columnName, columnString);
                        }
                        if (whereStatus.equals("FALSE"))
                        {
                            break;
                        }
                    }
                    if (whereStatus.equals("TRUE"))
                    {
                        jtbl.UpdateCurrentRow(c, v);
                    }
                    if (wc != (TinySQLWhere)null)
                    {
                        wc.clearValues(jtbl.table + "->" + jtbl.tableAlias);
                    }
                }
            }
            jtbl.close();
        }
コード例 #10
0
ファイル: TsResultSet.cs プロジェクト: bastie/NetVampire
 public TsResultSet(TinySQLWhere w, TinySQL dbeng)
 {
     dbengine       = dbeng;
     windowStart    = 0;
     whereC         = w;
     rows           = new java.util.Vector <Object>();
     rsColumns      = new java.util.Vector <Object>();
     selectColumns  = new java.util.Vector <Object>();
     orderByColumns = new java.util.Vector <Object>();
     tables         = new java.util.Vector <Object>();
 }
コード例 #11
0
 /**
  * Constructs a new {@code SequenceInputStream} using the two streams
  * {@code s1} and {@code s2} as the sequence of streams to read from.
  *
  * @param s1
  *            the first stream to get bytes from.
  * @param s2
  *            the second stream to get bytes from.
  * @throws NullPointerException
  *             if {@code s1} is {@code null}.
  */
 public SequenceInputStream(InputStream s1, InputStream s2)
 {
     if (s1 == null)
     {
         throw new java.lang.NullPointerException();
     }
     java.util.Vector <InputStream> inVector = new java.util.Vector <InputStream> (1);
     inVector.addElement(s2);
     e   = inVector.elements();
     inJ = s1;
 }
コード例 #12
0
        /*
         *  Update the actions based upon the contents of the substitute Vector.
         *  Only INSERT and UPDATE commands are supported at this time.
         */
        public void updateActions(java.util.Vector <Object> inputActions) //throws SQLException
        {
            java.util.Vector <Object>            values, originalValues;
            java.util.Hashtable <Object, Object> action;
            String actionType, valueString;
            int    i, j, subCount;

            if (actions == null)
            {
                actions = inputActions;
            }
            if (actions == null)
            {
                return;
            }
            for (i = 0; i < actions.size(); i++)
            {
                action     = (java.util.Hashtable <Object, Object>)actions.elementAt(i);
                actionType = (String)action.get("TYPE");
                if (actionType.equals("INSERT") | actionType.equals("UPDATE"))
                {
                    /*
                     *           Look for the original values (with the ? for parameters).
                     */
                    originalValues = (java.util.Vector <Object>)action.get("ORIGINAL_VALUES");
                    values         = (java.util.Vector <Object>)action.get("VALUES");
                    if (originalValues == (java.util.Vector <Object>)null)
                    {
                        originalValues = (java.util.Vector <Object>)values.clone();
                        action.put("ORIGINAL_VALUES", originalValues);
                    }
                    subCount = 0;
                    for (j = 0; j < originalValues.size(); j++)
                    {
                        valueString = (String)originalValues.elementAt(j);
                        if (valueString.equals("?"))
                        {
                            if (subCount > substitute.size() - 1)
                            {
                                throw new java.sql.SQLException("Substitution index " + subCount
                                                                + " not between 0 and "
                                                                + java.lang.Integer.toString(substitute.size() - 1));
                            }
                            values.setElementAt(substitute.elementAt(subCount), j);
                            subCount++;
                        }
                    }
                }
            }
        }
コード例 #13
0
ファイル: NamespaceSupport.cs プロジェクト: minam365/JavApi
 /*
  * Return anjava.util.Enumeration&lt;Object&gt; of all prefixes for a given URI whose
  * declarations are active in the current context.
  * This includes declarations from parent contexts that have
  * not been overridden.
  *
  * <p/>This method returns prefixes mapped to a specific Namespace
  * URI.  The xml: prefix will be included.  If you want only one
  * prefix that's mapped to the Namespace URI, and you don't care
  * which one you get, use the {@link #getPrefix getPrefix}
  *  method instead.
  *
  * <p/><strong>Note:</strong> the empty (default) prefix is <em>never</em> included
  * in thisjava.util.Enumeration&lt;Object&gt;; to check for the presence of a default
  * Namespace, use the {@link #getURI getURI} method with an
  * argument of "".
  *
  * @param uri The Namespace URI.
  * @return Anjava.util.Enumeration&lt;Object&gt; of prefixes (never empty).
  * @see #getPrefix
  * @see #getDeclaredPrefixes
  * @see #getURI
  */
 public java.util.Enumeration <Object> getPrefixes(String uri)
 {
     java.util.Vector <Object>      prefixes    = new java.util.Vector <Object>();
     java.util.Enumeration <Object> allPrefixes = getPrefixes();
     while (allPrefixes.hasMoreElements())
     {
         String prefix = (String)allPrefixes.nextElement();
         if (uri.equals(getURI(prefix)))
         {
             prefixes.addElement(prefix);
         }
     }
     return(prefixes.elements());
 }
コード例 #14
0
        /**
         * Obtain a new instance of a <code>DOMImplementationRegistry</code>.
         *
         *
         * The <code>DOMImplementationRegistry</code> is initialized by the
         * application or the implementation, depending on the context, by
         * first checking the value of the Java system property
         * <code>org.w3c.dom.DOMImplementationSourceList</code> and
         * the the service provider whose contents are at
         * "<code>META_INF/services/org.w3c.dom.DOMImplementationSourceList</code>"
         * The value of this property is a white-space separated list of
         * names of availables classes implementing the
         * <code>DOMImplementationSource</code> interface. Each class listed
         * in the class name list is instantiated and any exceptions
         * encountered are thrown to the application.
         *
         * @return an initialized instance of DOMImplementationRegistry
         * @throws ClassNotFoundException
         *     If any specified class can not be found
         * @throws InstantiationException
         *     If any specified class is an interface or abstract class
         * @throws IllegalAccessException
         *     If the default constructor of a specified class is not accessible
         * @throws ClassCastException
         *     If any specified class does not implement
         * <code>DOMImplementationSource</code>
         */
        public static DOMImplementationRegistry newInstance()
        {
            //throws     ClassNotFoundException,     InstantiationException,     IllegalAccessException,     ClassCastException {
            java.util.Vector <Object> sources = new java.util.Vector <Object>();

            java.lang.ClassLoader classLoader = getClassLoader();
            // fetch system property:
            String p = getSystemProperty(PROPERTY);

            //
            // if property is not specified then use contents of
            // META_INF/org.w3c.dom.DOMImplementationSourceList from classpath
            if (p == null)
            {
                p = getServiceValue(classLoader);
            }
            if (p == null)
            {
                //
                // DOM Implementations can modify here to add *additional* fallback
                // mechanisms to access a list of default DOMImplementationSources.
            }
            if (p != null)
            {
                java.util.StringTokenizer st = new java.util.StringTokenizer(p);
                while (st.hasMoreTokens())
                {
                    String sourceName = st.nextToken();
                    // Use context class loader, falling back to Class.forName
                    // if and only if this fails...
                    java.lang.Class sourceClass = null;
                    if (classLoader != null)
                    {
                        sourceClass = classLoader.loadClass(sourceName);
                    }
                    else
                    {
                        sourceClass = java.lang.Class.forName(sourceName);
                    }
                    DOMImplementationSource source =
                        (DOMImplementationSource)sourceClass.newInstance();
                    sources.addElement(source);
                }
            }
            return(new DOMImplementationRegistry(sources));
        }
コード例 #15
0
        /*
         * Format a where condition for display.
         */
        private String conditionToString(java.util.Vector <Object> inputWhereCondition)
        {
            String   comparison, conditionStatus;
            TsColumn leftColumn, rightColumn;

            if (inputWhereCondition.size() < 4)
            {
                return("");
            }
            java.lang.StringBuffer outputBuffer = new java.lang.StringBuffer("WHERE ");
            leftColumn      = (TsColumn)inputWhereCondition.elementAt(0);
            comparison      = (String)inputWhereCondition.elementAt(1);
            rightColumn     = (TsColumn)inputWhereCondition.elementAt(2);
            conditionStatus = (String)inputWhereCondition.elementAt(3);
            outputBuffer.append(leftColumn.getString() + " " + comparison
                                + " " + rightColumn.getString() + " " + conditionStatus);
            return(outputBuffer.toString());
        }
コード例 #16
0
 /**
  *
  * Updates the current row in the table.
  *
  * @param c Ordered Vector of column names
  * @param v Ordered Vector (must match order of c) of values
  * @see tinySQLTable#UpdateCurrentRow
  *
  */
 public override void UpdateCurrentRow(java.util.Vector <Object> c, java.util.Vector <Object> v)
 {// throws tinySQLException {
     // the Vectors v and c are expected to have the
     // same number of elements. It is also expected
     // that the elements correspond to each other,
     // such that value 1 of Vector v corresponds to
     // column 1 of Vector c, and so forth.
     //
     for (int i = 0; i < v.size(); i++)
     {
         // get the column name and the value, and
         // invoke UpdateCol() to update it.
         //
         String column = (String)c.elementAt(i);
         String value  = (String)v.elementAt(i);
         UpdateCol(column, value);
     }
 }
コード例 #17
0
        /**
         * Return a list of implementations that support the
         * desired features.
         *
         * @param features
         *            A string that specifies which features are required. This is
         *            a space separated list in which each feature is specified by
         *            its name optionally followed by a space and a version number.
         *            This is something like: "XML 1.0 Traversal +Events 2.0"
         * @return A list of DOMImplementations that support the desired features.
         */
        public DOMImplementationList getDOMImplementationList(String features)
        {
            java.util.Vector <Object> implementations = new java.util.Vector <Object>();
            int size = sources.size();

            for (int i = 0; i < size; i++)
            {
                DOMImplementationSource source =
                    (DOMImplementationSource)sources.elementAt(i);
                DOMImplementationList impls =
                    source.getDOMImplementationList(features);
                for (int j = 0; j < impls.getLength(); j++)
                {
                    DOMImplementation impl = impls.item(j);
                    implementations.addElement(impl);
                }
            }
            return(new IAC_DOMImplementationList(implementations));
        }
コード例 #18
0
        /**
         * Creates a table given the name and a vector of
         * column definition (tsColumn) arrays.<br>
         *
         * @param table_name the name of the table
         * @param v a Vector containing arrays of column definitions.
         * @see tinySQL#CreateTable
         */
        internal override void CreateTable(String table_name, java.util.Vector <Object> v)
        {//throws IOException, tinySQLException {
            // make the data directory, if it needs to be make
            //
            mkDataDirectory();

            // perform an implicit drop table.
            //
            DropTable(table_name);

            // create the table definition file
            //
            java.io.FileOutputStream fdef =
                new java.io.FileOutputStream(dataDir + "/" + table_name + ".def");

            // open it as a DataOutputStream
            //
            java.io.DataOutputStream def = new java.io.DataOutputStream(fdef);

            // write out the column definition for the _DELETED column
            //
            def.writeBytes("CHAR|_DELETED|1\n");

            // write out the rest of the columns' definition. The
            // definition consists of datatype, column name, and
            // size delimited by a pipe symbol
            //
            for (int i = 0; i < v.size(); i++)
            {
                def.writeBytes(((TsColumn)v.elementAt(i)).type + "|");
                def.writeBytes(((TsColumn)v.elementAt(i)).name + "|");
                def.writeBytes(((TsColumn)v.elementAt(i)).size + "\n");
            }

            // flush the DataOutputStream and jiggle the handle
            //
            def.flush();

            // close the file
            //
            fdef.close();
        }
コード例 #19
0
        /*
         * Find the input table alias in the list provided and return the table name
         * and alias in the form tableName=tableAlias.
         */
        public static String findTableAlias(String inputAlias, java.util.Vector <Object> tableList)
        //throws tinySQLException
        {
            int    i, aliasAt;
            String tableAndAlias, tableName, tableAlias;

            for (i = 0; i < tableList.size(); i++)
            {
                tableAndAlias = (String)tableList.elementAt(i);
                aliasAt       = tableAndAlias.indexOf("->");
                tableName     = tableAndAlias.substring(0, aliasAt);
                tableAlias    = tableAndAlias.substring(aliasAt + 2);
                if (inputAlias.equals(tableAlias))
                {
                    return(tableAndAlias);
                }
            }
            throw new TinySQLException("Unable to identify table alias "
                                       + inputAlias);
        }
コード例 #20
0
ファイル: DBFFileTable.cs プロジェクト: bastie/NetVampire
 /*
  * Updates the current row in the table.
  *
  * @param c Ordered Vector of column names
  * @param v Ordered Vector (must match order of c) of values
  * @see tinySQLTable#UpdateCurrentRow
  */
 public override void UpdateCurrentRow(java.util.Vector <Object> c, java.util.Vector <Object> v) //throws TinySQLException
 {
     /*
      *    The Vectors v and c are expected to have the
      *    same number of elements. It is also expected
      *    that the elements correspond to each other,
      *    such that value 1 of Vector v corresponds to
      *    column 1 of Vector c, and so forth.
      */
     for (int i = 0; i < v.size(); i++)
     {
         /*
          *       Get the column name and the value, and
          *       invoke UpdateCol() to update it.
          */
         String column = ((String)c.elementAt(i)).toUpperCase();
         String value  = (String)v.elementAt(i);
         UpdateCol(column, value);
     }
 }
コード例 #21
0
ファイル: ForEachTest.cs プロジェクト: bastie/NetVampire
        public void Test_ForEach_Vector()
        {
            java.lang.SystemJ.outJ.println("Vector foreach test");


            java.util.Vector <String> testArray = new java.util.Vector <String>();
            testArray.add("VampireAPI");
            testArray.add("supports");
            testArray.add("foreach statements");
            testArray.add("! Yeah!!!");

            // for count loop
            java.lang.SystemJ.outJ.println("for count loop: ");
            for (int i = 0; i < testArray.size(); i++)
            {
                java.lang.SystemJ.outJ.print(testArray.get(i));
                java.lang.SystemJ.outJ.print(" ");
            }
            java.lang.SystemJ.outJ.println();

            // for iterator loop
            java.lang.SystemJ.outJ.println("for iterator loop: ");
            for (java.util.Iterator <String> it = testArray.iterator(); it.hasNext();)
            {
                java.lang.SystemJ.outJ.print(it.next());
                java.lang.SystemJ.outJ.print(" ");
            }
            java.lang.SystemJ.outJ.println();

            // foreach loop
            java.lang.SystemJ.outJ.println("foreach loop: ");
            foreach (String text in testArray)
            {
                java.lang.SystemJ.outJ.print(text);
                java.lang.SystemJ.outJ.print(" ");
            }
            java.lang.SystemJ.outJ.println();


            Assert.True(true, "compiler OK");
        }
コード例 #22
0
		internal static String[] getPortForwarding(Session session)
		{
			java.util.Vector foo=new java.util.Vector();
			lock(pool)
			{
				for(int i=0; i<pool.size(); i++)
				{
					PortWatcher p=(PortWatcher)(pool.elementAt(i));
					if(p.session==session)
					{
						foo.addElement(p.lport+":"+p.host+":"+p.rport);
					}
				}
			}
			String[] bar=new String[foo.size()];
			for(int i=0; i<foo.size(); i++)
			{
				bar[i]=(String)(foo.elementAt(i));
			}
			return bar;
		}
コード例 #23
0
ファイル: PortWatcher.cs プロジェクト: weimingtom/pap2
 internal static String[] getPortForwarding(Session session)
 {
     java.util.Vector foo = new java.util.Vector();
     lock (pool)
     {
         for (int i = 0; i < pool.size(); i++)
         {
             PortWatcher p = (PortWatcher)(pool.elementAt(i));
             if (p.session == session)
             {
                 foo.addElement(p.lport + ":" + p.host + ":" + p.rport);
             }
         }
     }
     String[] bar = new String[foo.size()];
     for (int i = 0; i < foo.size(); i++)
     {
         bar[i] = (String)(foo.elementAt(i));
     }
     return(bar);
 }
コード例 #24
0
ファイル: TinySQLCmd.cs プロジェクト: bastie/NetVampire
        private static java.sql.Connection dbConnect(String tinySQLDir)// throws SQLException
        {
            java.sql.Connection       con = null;
            java.sql.DatabaseMetaData dbMeta;
            java.io.File   conPath;
            java.io.File[] fileList;
            String         tableName;

            java.sql.ResultSet tables_rs;
            conPath  = new java.io.File(tinySQLDir);
            fileList = conPath.listFiles();
            if (fileList == null)
            {
                java.lang.SystemJ.outJ.println(tinySQLDir + " is not a valid directory.");
                return((java.sql.Connection)null);
            }
            else
            {
                java.lang.SystemJ.outJ.println("Connecting to " + conPath.getAbsolutePath());
                con = java.sql.DriverManager.getConnection("jdbc:dbfFile:" + conPath, "", "");
            }
            dbMeta    = con.getMetaData();
            tables_rs = dbMeta.getTables(null, null, null, null);
            tableList = new java.util.Vector <Object>();
            while (tables_rs.next())
            {
                tableName = tables_rs.getString("TABLE_NAME");
                tableList.addElement(tableName);
            }
            if (tableList.size() == 0)
            {
                java.lang.SystemJ.outJ.println("There are no tinySQL tables in this directory.");
            }
            else
            {
                java.lang.SystemJ.outJ.println("There are " + tableList.size() + " tinySQL tables"
                                               + " in this directory.");
            }
            return(con);
        }
コード例 #25
0
ファイル: TinySQLGlobals.cs プロジェクト: bastie/NetVampire
        public static void readLongNames(String inputDataDir)
        {
            String fullPath, longNameRecord;

            String[]       fields;
            FieldTokenizer ft;

            java.io.File longColumnNameFile;
            dataDir = inputDataDir;
            java.io.BufferedReader longNameReader = (java.io.BufferedReader)null;
            fullPath           = dataDir + fileSep + "TINYSQL_LONG_COLUMN_NAMES.dat";
            longColumnNames    = new java.util.Vector <Object>();
            longColumnNameFile = new java.io.File(fullPath);
            if (longColumnNameFile.exists())
            {
                try
                {
                    longNameReader = new java.io.BufferedReader(new java.io.FileReader(fullPath));
                    while ((longNameRecord = longNameReader.readLine()) != null)
                    {
                        ft     = new FieldTokenizer(longNameRecord, '|', false);
                        fields = ft.getFields();
                        longColumnNames.addElement(fields[0]);
                        longColumnNames.addElement(fields[1]);
                    }
                    longNameReader.close();
                    longNamesInFileCount = longColumnNames.size() / 2;
                    if (debug)
                    {
                        java.lang.SystemJ.outJ.println("Long Names read: " + longNamesInFileCount);
                    }
                }
                catch (Exception readEx)
                {
                    java.lang.SystemJ.outJ.println("Reader exception " + readEx.getMessage());
                    longNamesInFileCount = 0;
                }
            }
        }
コード例 #26
0
ファイル: DBFFileTable.cs プロジェクト: bastie/NetVampire
        /*
         * Insert a row. If c or v == null, insert a blank row
         *
         * @param c Ordered Vector of column names
         * @param v Ordered Vector (must match order of c) of values
         * @see tinySQLTable#InsertRow()
         *
         */
        public override void InsertRow(java.util.Vector <Object> c, java.util.Vector <Object> v) //throws TinySQLException
        {
            try
            {
                /*
                 *       Go to the end of the file, then write out the not deleted indicator
                 */
                ftbl.seek(ftbl.length());
                ftbl.write(RECORD_IS_NOT_DELETED);

                /*
                 *       Write out a blank record
                 */
                for (int i = 1; i < dbfHeader.recordLength; i++)
                {
                    ftbl.write(' ');
                }
                int numRec = (int)dbfHeader.numRecords + 1;
                currentRecordNumber = numRec;
                dbfHeader.setNumRecords(ftbl, numRec);
            }
            catch (Exception e)
            {
                if (TinySQLGlobals.DEBUG)
                {
                    java.lang.SystemJ.err.println(e.toString());                      // e.printStackTrace();
                }
                throw new TinySQLException(e.getMessage());
            }
            if (c != null && v != null)
            {
                UpdateCurrentRow(c, v);
            }
            else
            {
                dbfHeader.setTimestamp(ftbl);
            }
        }
コード例 #27
0
        /*
         * Move the input table to the top of the selection list.
         */
        public static void setPriority(java.util.Vector <Object> inputList, String inputTable)
        {
            String tableName;
            int    i;

            if (inputList == null)
            {
                return;
            }
            for (i = 0; i < inputList.size(); i++)
            {
                tableName = (String)inputList.elementAt(i);
                if (tableName.equals(inputTable))
                {
                    if (i > 0)
                    {
                        inputList.removeElementAt(i);
                        inputList.insertElementAt(tableName, 0);
                    }
                    break;
                }
            }
        }
コード例 #28
0
ファイル: NamespaceSupport.cs プロジェクト: minam365/JavApi
            /*
             * Declare a Namespace prefix for this context.
             *
             * @param prefix The prefix to declare.
             * @param uri The associated Namespace URI.
             * @see org.xml.sax.helpers.NamespaceSupport#declarePrefix
             */
            internal void declarePrefix(String prefix, String uri)
            {
                // Lazy processing...
                if (!declsOK)
                {
                    throw new java.lang.IllegalStateException(
                              "can't declare any more prefixes in this context");
                }
                if (!declSeen)
                {
                    copyTables();
                }
                if (declarations == null)
                {
                    declarations = new java.util.Vector <Object>();
                }

                prefix = prefix.intern();
                uri    = uri.intern();
                if ("".equals(prefix))
                {
                    if ("".equals(uri))
                    {
                        defaultNS = null;
                    }
                    else
                    {
                        defaultNS = uri;
                    }
                }
                else
                {
                    prefixTable.put(prefix, uri);
                    uriTable.put(uri, prefix); // may wipe out another prefix
                }
                declarations.addElement(prefix);
            }
コード例 #29
0
ファイル: TsRow.cs プロジェクト: bastie/NetVampire
 /**
  *
  * Given a column name, returns its value as a string.
  *
  * @param column the name of the column
  *
  */
 public void setOrderBy(java.util.Vector <Object> inputColumns)
 {
     orderByColumns = inputColumns;
 }
コード例 #30
0
ファイル: ParserAdapter.cs プロジェクト: sailesh341/JavApi
        //throws SAXException
        /**
         * Adapter implementation method; do not call.
         * Adapt a SAX1 startElement event.
         *
         * <p>If necessary, perform Namespace processing.</p>
         *
         * @param qName The qualified (prefixed) name.
         * @param qAtts The XML attribute list (with qnames).
         * @exception SAXException The client may raise a
         *            processing exception.
         */
        public void startElement(String qName, AttributeList qAtts)
        {
            // These are exceptions from the
            // first pass; they should be
            // ignored if there's a second pass,
            // but reported otherwise.
            java.util.Vector<SAXException> exceptions = null;

            // If we're not doing Namespace
            // processing, dispatch this quickly.
            if (!namespaces)
            {
                if (contentHandler != null)
                {
                    attAdapter.setAttributeList(qAtts);
                    contentHandler.startElement("", "", qName.intern(),
                                    attAdapter);
                }
                return;
            }

            // OK, we're doing Namespace processing.
            nsSupport.pushContext();
            int length = qAtts.getLength();

            // First pass:  handle NS decls
            for (int i = 0; i < length; i++)
            {
                String attQName = qAtts.getName(i);

                if (!attQName.startsWith("xmlns"))
                    continue;
                // Could be a declaration...
                String prefix;
                int n = attQName.indexOf(':');

                // xmlns=...
                if (n == -1 && attQName.length() == 5)
                {
                    prefix = "";
                }
                else if (n != 5)
                {
                    // XML namespaces spec doesn't discuss "xmlnsf:oo"
                    // (and similarly named) attributes ... at most, warn
                    continue;
                }
                else 		// xmlns:foo=...
                    prefix = attQName.substring(n + 1);

                String value = qAtts.getValue(i);
                if (!nsSupport.declarePrefix(prefix, value))
                {
                    reportError("Illegal Namespace prefix: " + prefix);
                    continue;
                }
                if (contentHandler != null)
                    contentHandler.startPrefixMapping(prefix, value);
            }

            // Second pass: copy all relevant
            // attributes into the SAX2 AttributeList
            // using updated prefix bindings
            atts.clear();
            for (int i = 0; i < length; i++)
            {
                String attQName = qAtts.getName(i);
                String type = qAtts.getType(i);
                String value = qAtts.getValue(i);

                // Declaration?
                if (attQName.startsWith("xmlns"))
                {
                    String prefix;
                    int n = attQName.indexOf(':');

                    if (n == -1 && attQName.length() == 5)
                    {
                        prefix = "";
                    }
                    else if (n != 5)
                    {
                        // XML namespaces spec doesn't discuss "xmlnsf:oo"
                        // (and similarly named) attributes ... ignore
                        prefix = null;
                    }
                    else
                    {
                        prefix = attQName.substring(6);
                    }
                    // Yes, decl:  report or prune
                    if (prefix != null)
                    {
                        if (prefixes)
                        {
                            if (uris)
                                // note funky case:  localname can be null
                                // when declaring the default prefix, and
                                // yet the uri isn't null.
                                atts.addAttribute(NamespaceSupport.XMLNS, prefix,
                                    attQName.intern(), type, value);
                            else
                                atts.addAttribute("", "",
                                    attQName.intern(), type, value);
                        }
                        continue;
                    }
                }

                // Not a declaration -- report
                try
                {
                    String[] attName = processName(attQName, true, true);
                    atts.addAttribute(attName[0], attName[1], attName[2],
                              type, value);
                }
                catch (SAXException e)
                {
                    if (exceptions == null)
                        exceptions = new java.util.Vector<SAXException>();
                    exceptions.addElement(e);
                    atts.addAttribute("", attQName, attQName, type, value);
                }
            }

            // now handle the deferred exception reports
            if (exceptions != null && errorHandler != null)
            {
                for (int i = 0; i < exceptions.size(); i++)
                    errorHandler.error((SAXParseException)
                            (exceptions.elementAt(i)));
            }

            // OK, finally report the event.
            if (contentHandler != null)
            {
                String[] name = processName(qName, false, false);
                contentHandler.startElement(name[0], name[1], name[2], atts);
            }
        }
コード例 #31
0
        public TinySQLParser(java.io.InputStream sqlInput, TinySQL inputEngine)
        //throws TinySQLException
        {
            java.io.StreamTokenizer st;
            FieldTokenizer          ft;

            java.io.Reader r;
            String         nextToken, upperField, nextField, keyWord = (String)null;

            java.lang.StringBuffer cmdBuffer, inputSQLBuffer;
            int lastIndex, keyIndex;

            r               = new java.io.BufferedReader(new java.io.InputStreamReader(sqlInput));
            dbEngine        = inputEngine;
            actionList      = new java.util.Vector <Object>();
            columnList      = new java.util.Vector <Object>();
            columns         = new java.util.Vector <Object>();
            columnAliasList = new java.util.Vector <Object>();
            contextList     = new java.util.Vector <Object>();
            valueList       = new java.util.Vector <Object>();
            tableName       = (String)null;
            whereClause     = (TinySQLWhere)null;

/*
 *    The tableList is a list of table names, in the optimal order
 *    in which they should be scanned for the SELECT phrase.
 *    The java.util.Hashtable<Object,Object> tables contains table objects keyed by table
 *    alias and name.
 */
            tableList = new java.util.Vector <Object>();
            tables    = new java.util.Hashtable <Object, Object>();
            tables.put("TABLE_SELECT_ORDER", tableList);
            try
            {
                st = new java.io.StreamTokenizer(r);
                st.eolIsSignificant(false);
                st.wordChars('\'', '}');
                st.wordChars('?', '?');
                st.wordChars('"', '.');
                st.ordinaryChars('0', '9');
                st.wordChars('0', '9');
                cmdBuffer      = new java.lang.StringBuffer();
                inputSQLBuffer = new java.lang.StringBuffer();
                while (st.nextToken() != java.io.StreamTokenizer.TT_EOF)
                {
                    if (st.ttype == java.io.StreamTokenizer.TT_WORD)
                    {
                        nextToken = st.sval.trim();
                    }
                    else
                    {
                        continue;
                    }
                    if (inputSQLBuffer.length() > 0)
                    {
                        inputSQLBuffer.append(" ");
                    }
                    inputSQLBuffer.append(nextToken);
                }
                ft = new FieldTokenizer(inputSQLBuffer.toString(), ' ', false);
                while (ft.hasMoreFields())
                {
                    nextField  = ft.nextField();
                    upperField = nextField.toUpperCase();
                    if (statementType == (String)null)
                    {
                        statementType = upperField;
                        lastIndex     = getKeywordIndex(statementType, statementType);
                        if (lastIndex != 0)
                        {
                            throwException(9);
                        }
                        keyWord = statementType;
                    }
                    else
                    {
                        keyIndex = getKeywordIndex(statementType, upperField);
                        if (keyIndex < 0)
                        {
                            if (cmdBuffer.length() > 0)
                            {
                                cmdBuffer.append(" ");
                            }
                            cmdBuffer.append(nextField);
                        }
                        else
                        {
                            setPhrase(keyWord, cmdBuffer.toString());
                            cmdBuffer = new java.lang.StringBuffer();
                            keyWord   = upperField;
                            if (TinySQLGlobals.PARSER_DEBUG)
                            {
                                java.lang.SystemJ.outJ.println("Found keyword " + keyWord);
                            }
                        }
                    }
                }
                if (keyWord != (String)null)
                {
                    setPhrase(keyWord, cmdBuffer.toString());
                }
                addAction();
                if (TinySQLGlobals.PARSER_DEBUG)
                {
                    java.lang.SystemJ.outJ.println("SQL:" + inputSQLBuffer.toString());
                }
            } catch (Exception ex) {
                if (TinySQLGlobals.DEBUG)
                {
                    java.lang.SystemJ.outJ.println(ex.StackTrace);                 //ex.printStackTrace(java.lang.SystemJ.outJ);
                }
                throw new TinySQLException(ex.getMessage());
            }
        }
コード例 #32
0
        //throws IOException, TinySQLException;

        /*
         * Deletes Columns given a tableName, and a Vector of
         * column definition (tsColumn) arrays.<br>
         *
         * ALTER TABLE table DROP [ COLUMN ] column { RESTRICT | CASCADE }
         */
        internal abstract void AlterTableDropCol(String tableName, java.util.Vector <Object> v);
コード例 #33
0
 /*
  * Creates a table given a tableName, and a Vector of column
  * definitions.
  *
  * The column definitions are an array of tsColumn
  */
 internal abstract void CreateTable(String tableName, java.util.Vector <Object> v);
コード例 #34
0
ファイル: NamespaceSupport.cs プロジェクト: sailesh341/JavApi
 /**
  * Return anjava.util.Enumeration&lt;Object&gt; of all prefixes for a given URI whose
  * declarations are active in the current context.
  * This includes declarations from parent contexts that have
  * not been overridden.
  *
  * <p/>This method returns prefixes mapped to a specific Namespace
  * URI.  The xml: prefix will be included.  If you want only one
  * prefix that's mapped to the Namespace URI, and you don't care
  * which one you get, use the {@link #getPrefix getPrefix}
  *  method instead.
  *
  * <p/><strong>Note:</strong> the empty (default) prefix is <em>never</em> included
  * in thisjava.util.Enumeration&lt;Object&gt;; to check for the presence of a default
  * Namespace, use the {@link #getURI getURI} method with an
  * argument of "".
  *
  * @param uri The Namespace URI.
  * @return Anjava.util.Enumeration&lt;Object&gt; of prefixes (never empty).
  * @see #getPrefix
  * @see #getDeclaredPrefixes
  * @see #getURI
  */
 public java.util.Enumeration<Object> getPrefixes(String uri)
 {
     java.util.Vector<Object> prefixes = new java.util.Vector<Object>();
     java.util.Enumeration<Object> allPrefixes = getPrefixes();
     while (allPrefixes.hasMoreElements()) {
     String prefix = (String)allPrefixes.nextElement();
     if (uri.equals(getURI(prefix))) {
     prefixes.addElement(prefix);
     }
     }
     return prefixes.elements();
 }
コード例 #35
0
		internal static String[] getPortForwarding(Session session)
		{
			java.util.Vector foo=new java.util.Vector();
			lock(pool)
			{
				for(int i=0; i<pool.size(); i++)
				{
					Object[] bar=(Object[])(pool.elementAt(i));
					if(bar[0]!=session) continue;
					if(bar[3]==null){ foo.addElement(bar[1]+":"+bar[2]+":"); }
					else{ foo.addElement(bar[1]+":"+bar[2]+":"+bar[3]); }
				}
			}
			String[] bar2=new String[foo.size()];
			for(int i=0; i<foo.size(); i++)
			{
				bar2[i]=(String)(foo.elementAt(i));
			}
			return bar2;
		}
コード例 #36
0
ファイル: ChannelSftp.cs プロジェクト: joconno4/MediaPortal-2
		protected void addRunningThread(Thread thread)
		{
			if(threadList==null)threadList=new java.util.Vector();
			threadList.add(thread);
		}
コード例 #37
0
ファイル: ChannelSftp.cs プロジェクト: joconno4/MediaPortal-2
		public java.util.Vector ls(String path) 
		{ //throws SftpException{
			try
			{
				path=remoteAbsolutePath(path);

				String dir=path;
				byte[] pattern=null;
				SftpATTRS attr=null;
				if(isPattern(dir) || 
					((attr=stat(dir))!=null && !attr.isDir()))
				{
					int foo=path.lastIndexOf('/');
					dir=path.substring(0, ((foo==0)?1:foo));
					pattern=path.substring(foo+1).getBytes();
				}

				sendOPENDIR(dir.getBytes());

				Header _header=new Header();
				_header=header(buf, _header);
				int length=_header.length;
				int type=_header.type;
				buf.rewind();
				fill(buf.buffer, 0, length);

				if(type!=SSH_FXP_STATUS && type!=SSH_FXP_HANDLE)
				{
					throw new SftpException(SSH_FX_FAILURE, "");
				}
				if(type==SSH_FXP_STATUS)
				{
					int i=buf.getInt();
					throwStatusError(buf, i);
				}

				byte[] handle=buf.getString();         // filename

				java.util.Vector v=new java.util.Vector();
				while(true)
				{
					sendREADDIR(handle);

					_header=header(buf, _header);
					length=_header.length;
					type=_header.type;
					if(type!=SSH_FXP_STATUS && type!=SSH_FXP_NAME)
					{
						throw new SftpException(SSH_FX_FAILURE, "");
					}
					if(type==SSH_FXP_STATUS)
					{ 
						buf.rewind();
						fill(buf.buffer, 0, length);
						int i=buf.getInt();
						if(i==SSH_FX_EOF)
							break;
						throwStatusError(buf, i);
					}

					buf.rewind();
					fill(buf.buffer, 0, 4); length-=4;
					int count=buf.getInt();

					byte[] str;
					int flags;

					buf.reset();
					while(count>0)
					{
						if(length>0)
						{
							buf.shift();
							int j=(buf.buffer.Length>(buf.index+length)) ? length : (buf.buffer.Length-buf.index);
							int i=fill(buf.buffer, buf.index, j);
							buf.index+=i;
							length-=i;
						}
						byte[] filename=buf.getString();
						str=buf.getString();
						String longname=new String(str);

						SftpATTRS attrs=SftpATTRS.getATTR(buf);
						if(pattern==null || Util.glob(pattern, filename))
						{
							v.addElement(new LsEntry(new String(filename), longname, attrs));
						}

						count--; 
					}
				}
				_sendCLOSE(handle, _header);
				return v;
			}
			catch(Exception e)
			{
				if(e is SftpException) throw (SftpException)e;
				throw new SftpException(SSH_FX_FAILURE, "");
			}
		}
コード例 #38
0
ファイル: NamespaceSupport.cs プロジェクト: sailesh341/JavApi
            /**
             * Declare a Namespace prefix for this context.
             *
             * @param prefix The prefix to declare.
             * @param uri The associated Namespace URI.
             * @see org.xml.sax.helpers.NamespaceSupport#declarePrefix
             */
            internal void declarePrefix(String prefix, String uri)
            {
                // Lazy processing...
                if (!declsOK)
                throw new java.lang.IllegalStateException (
                "can't declare any more prefixes in this context");
                if (!declSeen) {
                copyTables();
                }
                if (declarations == null) {
                declarations = new java.util.Vector<Object>();
                }

                prefix = prefix.intern();
                uri = uri.intern();
                if ("".equals(prefix)) {
                if ("".equals(uri)) {
                defaultNS = null;
                } else {
                defaultNS = uri;
                }
                } else {
                prefixTable.put(prefix, uri);
                uriTable.put(uri, prefix); // may wipe out another prefix
                }
                declarations.addElement(prefix);
            }
コード例 #39
0
ファイル: NamespaceSupport.cs プロジェクト: sailesh341/JavApi
 /**
  * (Re)set the parent of this Namespace context.
  * The context must either have been freshly constructed,
  * or must have been cleared.
  *
  * @param context The parent Namespace context object.
  */
 internal void setParent(Context parent)
 {
     this.parent = parent;
     declarations = null;
     prefixTable = parent.prefixTable;
     uriTable = parent.uriTable;
     elementNameTable = parent.elementNameTable;
     attributeNameTable = parent.attributeNameTable;
     defaultNS = parent.defaultNS;
     declSeen = false;
     declsOK = true;
 }
コード例 #40
0
ファイル: DriverManager.cs プロジェクト: sailesh341/JavApi
 /**
  * Returns an {@code Enumeration} that contains all of the loaded JDBC
  * drivers that the current caller can access.
  *
  * @return An {@code Enumeration} containing all the currently loaded JDBC
  *         {@code Drivers}.
  */
 public static java.util.Enumeration<Driver> getDrivers()
 {
     java.lang.ClassLoader callerClassLoader = java.lang.Runtime.getRuntime().getClass().getClassLoader();// Basties note: sometime do the same as VM.callerClassLoader();
     /*
      * Synchronize to avoid clashes with additions and removals of drivers
      * in the DriverSet
      */
     lock (theDrivers)
     {
         /*
          * Create the Enumeration by building a Vector from the elements of
          * the DriverSet
          */
         java.util.Vector<Driver> theVector = new java.util.Vector<Driver>();
         java.util.Iterator<Driver> theIterator = theDrivers.iterator();
         while (theIterator.hasNext())
         {
             Driver theDriver = theIterator.next();
             if (DriverManager.isClassFromClassLoader(theDriver,
                     callerClassLoader))
             {
                 theVector.add(theDriver);
             }
         }
         return theVector.elements();
     }
 }