Esempio n. 1
0
  /**
   * Retrieves the <code>User</code> objects representing the database users that are visible to the
   * <code>User</code> object represented by the <code>session</code> argument.
   *
   * <p>If the <code>session</code> argument's <code>User</code> object attribute has isAdmin() true
   * (directly or by virtue of a Role), then all of the <code>User</code> objects in this collection
   * are considered visible. Otherwise, only this object's special <code>PUBLIC</code> <code>User
   * </code> object attribute and the session <code>User</code> object, if it exists in this
   * collection, are considered visible.
   *
   * <p>
   *
   * @param session The <code>Session</code> object used to determine visibility
   * @return a list of <code>User</code> objects visible to the <code>User</code> object contained
   *     by the <code>session</code> argument.
   */
  public HsqlArrayList listVisibleUsers(Session session) {

    HsqlArrayList list;
    User user;
    boolean isAdmin;
    String sessionName;
    String userName;

    list = new HsqlArrayList();
    isAdmin = session.isAdmin();
    sessionName = session.getUsername();

    if (userList == null || userList.size() == 0) {
      return list;
    }

    for (int i = 0; i < userList.size(); i++) {
      user = (User) userList.get(i);

      if (user == null) {
        continue;
      }

      userName = user.getNameString();

      if (isAdmin) {
        list.add(user);
      } else if (sessionName.equals(userName)) {
        list.add(user);
      }
    }

    return list;
  }
Esempio n. 2
0
  void addTableColumns(Expression expression, HashSet exclude) {

    HsqlArrayList list = new HsqlArrayList();
    Table table = getTable();
    int count = table.getColumnCount();

    for (int i = 0; i < count; i++) {
      ColumnSchema column = table.getColumn(i);
      String columnName =
          columnAliases == null ? column.getName().name : (String) columnAliases.get(i);

      if (exclude != null && exclude.contains(columnName)) {
        continue;
      }

      Expression e = new ExpressionColumn(this, column, i);

      list.add(e);
    }

    Expression[] nodes = new Expression[list.size()];

    list.toArray(nodes);

    expression.nodes = nodes;
  }
Esempio n. 3
0
  /** Add all columns to a list of expressions */
  void addTableColumns(HsqlArrayList exprList) {

    if (namedJoinColumns != null) {
      int count = exprList.size();
      int position = 0;

      for (int i = 0; i < count; i++) {
        Expression e = (Expression) exprList.get(i);
        String columnName = e.getColumnName();

        if (namedJoinColumns.contains(columnName)) {
          if (position != i) {
            exprList.remove(i);
            exprList.add(position, e);
          }

          e = getColumnExpression(columnName);

          exprList.set(position, e);

          position++;
        }
      }
    }

    addTableColumns(exprList, exprList.size(), namedJoinColumns);
  }
Esempio n. 4
0
  public String[] getInitialSchemaSQL() {

    HsqlArrayList list = new HsqlArrayList(userList.size());

    for (int i = 0; i < userList.size(); i++) {
      User user = (User) userList.get(i);

      if (user.isSystem) {
        continue;
      }

      HsqlName name = user.getInitialSchema();

      if (name == null) {
        continue;
      }

      list.add(user.getInitialSchemaSQL());
    }

    String[] array = new String[list.size()];

    list.toArray(array);

    return array;
  }
Esempio n. 5
0
  /** Add all columns to a list of expressions */
  int addTableColumns(HsqlArrayList expList, int position, HashSet exclude) {

    Table table = getTable();
    int count = table.getColumnCount();

    for (int i = 0; i < count; i++) {
      ColumnSchema column = table.getColumn(i);
      String columnName =
          columnAliases == null ? column.getName().name : (String) columnAliases.get(i);

      if (exclude != null && exclude.contains(columnName)) {
        continue;
      }

      Expression e = new ExpressionColumn(this, column, i);

      expList.add(position++, e);
    }

    return position;
  }
Esempio n. 6
0
  public void setBlockBytes(byte[] dataBytes, int blockAddress, int blockCount) {

    int dataBlockOffset = 0;

    while (blockCount > 0) {
      int largeBlockIndex = blockAddress / blocksInLargeBlock;
      int largeBlockLimit = (blockAddress + blockCount) / blocksInLargeBlock;

      if ((blockAddress + blockCount) % blocksInLargeBlock != 0) {
        largeBlockLimit++;
      }

      if (largeBlockIndex >= byteStoreList.size()) {
        byteStoreList.add(new byte[largeBlockSize]);
      }

      byte[] largeBlock = (byte[]) byteStoreList.get(largeBlockIndex);
      int blockOffset = blockAddress % blocksInLargeBlock;
      int currentBlockCount = blockCount;

      if ((blockOffset + currentBlockCount) > blocksInLargeBlock) {
        currentBlockCount = blocksInLargeBlock - blockOffset;
      }

      System.arraycopy(
          dataBytes,
          dataBlockOffset * lobBlockSize,
          largeBlock,
          blockOffset * lobBlockSize,
          currentBlockCount * lobBlockSize);

      blockAddress += currentBlockCount;
      dataBlockOffset += currentBlockCount;
      blockCount -= currentBlockCount;
    }
  }