/* (non-Javadoc)
@see org.parosproxy.paros.db.paros.TableContext#read(long)
162872
@Override
	public synchronized RecordContext read(long dataId) throws DatabaseException {
		try {
			psRead.setLong(1, dataId);
			
			try (ResultSet rs = psRead.executeQuery()) {
				RecordContext result = build(rs);
				return result;
			}
		} catch (SQLException e) {
			throw new DatabaseException(e);
		}
	}
734798
public static Long readLong(String value, Long defaultValue) {
		if (!StringUtils.hasText(value)) return defaultValue;
		
		return Long.valueOf(value);
	}
769207
private Map<C, Long> readLockColumns(boolean readDataColumns) throws Exception {
        Map<C, Long> result = Maps.newLinkedHashMap();
        // Read all the columns
        if (readDataColumns) {
            columns = new OrderedColumnMap<C>();
            ColumnList<C> lockResult = keyspace
                .prepareQuery(columnFamily)
                    .setConsistencyLevel(consistencyLevel)
                    .getKey(key)
                .execute()
                    .getResult();
    
            for (Column<C> c : lockResult) {
                if (columnStrategy.isLockColumn(c.getName()))
                    result.put(c.getName(), readTimeoutValue(c));
                else 
                    columns.add(c);
            }
        }
        // Read only the lock columns
        else {
            ColumnList<C> lockResult = keyspace
                .prepareQuery(columnFamily)
                    .setConsistencyLevel(consistencyLevel)
                    .getKey(key)
                    .withColumnRange(columnStrategy.getLockColumnRange())
                .execute()
                    .getResult();

            for (Column<C> c : lockResult) {
                result.put(c.getName(), readTimeoutValue(c));
            }

        }
        return result;    
    }
530898
public long getLong(String key, long defaultValue) {
    if (containsKey(key)) {
      return Long.parseLong(get(key));
    } else {
      return defaultValue;
    }
  }
1077359
public long getLong( String key, long defaultValue )
        throws MissingResourceException
    {
        try
        {
            return getLong( key );
        }
        catch( MissingResourceException mre )
        {
            return defaultValue;
        }
    }
1195644
private void readRecord(byte[] buffer, Table table)
   {
      //System.out.println(ByteArrayHelper.hexdump(buffer, true, 16, ""));
      int deletedFlag = getShort(buffer, 0);
      if (deletedFlag != 0)
      {
         Map<String, Object> row = new HashMap<String, Object>();
         for (ColumnDefinition column : m_definition.getColumns())
         {
            Object value = column.read(0, buffer);
            //System.out.println(column.getName() + ": " + value);
            row.put(column.getName(), value);
         }

         table.addRow(m_definition.getPrimaryKeyColumnName(), row);
      }
   }
862345
long getLong(int bp) {
        DataInputStream bufin =
            new DataInputStream(new ByteArrayInputStream(buf, bp, 8));
        try {
            return bufin.readLong();
        } catch (IOException e) {
            throw new AssertionError(e);
        }
    }
696444
private Map<String, Long> readLockColumns(boolean readDataColumns) throws Exception {
        Map<String, Long> result = Maps.newLinkedHashMap();
        // Read all the columns
        if (readDataColumns) {
            columns = new OrderedColumnMap<String>();
            ColumnList<String> lockResult = keyspace
                .prepareQuery(columnFamily)
                    .setConsistencyLevel(consistencyLevel)
                    .getKey(key)
                .execute()
                    .getResult();
    
            for (Column<String> c : lockResult) {
                if (c.getName().startsWith(prefix))
                    result.put(c.getName(), readTimeoutValue(c));
                else 
                    columns.add(c);
            }
        }
        // Read only the lock columns
        else {
            ColumnList<String> lockResult = keyspace
                .prepareQuery(columnFamily)
                    .setConsistencyLevel(consistencyLevel)
                    .getKey(key)
                    .withColumnRange(new RangeBuilder().setStart(prefix + "\u0000").setEnd(prefix + "\uFFFF").build())
                .execute()
                    .getResult();

            for (Column<String> c : lockResult) {
                result.put(c.getName(), readTimeoutValue(c));
            }

        }
        return result;    
    }
231900
private void readObject(java.io.ObjectInputStream s)
      throws java.io.IOException, ClassNotFoundException {
    s.defaultReadObject();

    // Read in array length and allocate array
    int length = s.readInt();
    this.longs = new AtomicLongArray(length);

    // Read in all elements in the proper order.
    for (int i = 0; i < length; i++) {
      set(i, s.readDouble());
    }
  }
1107545
public Long getAsLong(String key) {
        Object value = mValues.get(key);
        try {
            return value != null ? ((Number) value).longValue() : null;
        } catch (ClassCastException e) {
            if (value instanceof CharSequence) {
                try {
                    return Long.valueOf(value.toString());
                } catch (NumberFormatException e2) {
                    logger.log(Level.SEVERE,"Cannot parse Long value for " + value + " at key "+ key);
                    return null;
                }
            } else {
                logger.log(Level.SEVERE,"Cannot case value for "+ key + "to a Long "+ value,e);
                return null;
            }
        }
    }
910257
private void readObject(final java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException {
     timeStamp = in.readLong();
   }
821809
@Override
    public long getLong(int columnIndex) throws SQLException {
        checkColumnBounds(columnIndex);
        try {
            Long longValue = getPrivateInteger(columnIndex);
            return longValue;
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
243129
final void setPSLong(PreparedStatement ps, int index, long value) throws SQLException {
        if (usingDB2Connect || usingSQLServer || usingDB2zOS) { // LIDB2775.25 zOS
            ps.setBigDecimal(index, BigDecimal.valueOf(value));
        } else {
            ps.setLong(index, value);
        }
    }
507039
@Override
	public Long getPropertyLong(String key, long aDefault)
	{
		return getPropertyLong(key, Long.valueOf(aDefault));
	}
276168
protected void readFromDB4Links()
        throws CacheReloadException
    {
        Connection con = null;
        try {
            con = Context.getConnection();
            final SQLSelect select = new SQLSelect()
                            .column(0, "TYPEID")
                            .column(0, "TOID")
                            .column(1, "TYPEID")
                            .column(1, "NAME")
                            .from("T_CMABSTRACT2ABSTRACT", 0)
                            .leftJoin("T_CMABSTRACT", 1, "ID", 0, "TOID")
                            .addPart(SQLPart.WHERE)
                            .addColumnPart(0, "FROMID")
                            .addPart(SQLPart.EQUAL)
                            .addValuePart(getId());

            final Statement stmt = con.createStatement();
            final ResultSet rs = stmt.executeQuery(select.getSQL());

            AbstractAdminObject.LOG.debug("Reading Links for '{}'", getName());

            final List<Object[]> values = new ArrayList<>();
            while (rs.next()) {
                final long conTypeId = rs.getLong(1);
                final long toId = rs.getLong(2);
                final long toTypeId = rs.getLong(3);
                final String toName = rs.getString(4);
                values.add(new Object[] { conTypeId, toId, toTypeId, toName.trim() });
            }
            rs.close();
            stmt.close();
            con.commit();
            con.close();
            for (final Object[] row : values) {
                final UUID conTypeUUID = Type.getUUID4Id((Long) row[0]);
                AbstractAdminObject.LOG.debug("     Connection Type UUID: {}", conTypeUUID);
                final UUID toTypeUUID = Type.getUUID4Id((Long) row[2]);
                AbstractAdminObject.LOG.debug("     To Type UUID: {}", toTypeUUID);
                if (conTypeUUID != null && toTypeUUID != null) {
                    setLinkProperty(conTypeUUID, (Long) row[1], toTypeUUID, String.valueOf(row[3]));
                    AbstractAdminObject.LOG.debug("     ID: {}, name: {}", row[1], row[3]);
                }
            }
        } catch (final SQLException e) {
            throw new CacheReloadException("could not read db links for " + "'" + getName() + "'", e);
            // CHECKSTYLE:OFF
        } catch (final RuntimeException e) {
            // CHECKSTYLE:ON
            throw new CacheReloadException("could not read db links for " + "'" + getName() + "'", e);
        } catch (final EFapsException e) {
            throw new CacheReloadException("could not read properties for " + "'" + getName() + "'", e);
        } finally {
            try {
                if (con != null && !con.isClosed()) {
                    con.close();
                }
            } catch (final SQLException e) {
                throw new CacheReloadException("Cannot read a type for an attribute.", e);
            }
        }
    }
414284
public TTable readTable(
			UserCoreConnection<TColumn, TTable, TRow, TResult> db) {

		List<TColumn> columnList = new ArrayList<TColumn>();

		TResult result = db.rawQuery(
				"PRAGMA table_info(" + CoreSQLUtils.quoteWrap(tableName) + ")",
				null);
		try {
			while (result.moveToNext()) {
				int index = result.getInt(result.getColumnIndex(CID));
				String name = result.getString(result.getColumnIndex(NAME));
				String type = result.getString(result.getColumnIndex(TYPE));
				boolean notNull = result
						.getInt(result.getColumnIndex(NOT_NULL)) == 1;
				boolean primaryKey = result.getInt(result.getColumnIndex(PK)) == 1;

				// If the type has a max limit on it, pull it off
				Long max = null;
				if (type != null && type.endsWith(")")) {
					int maxStart = type.indexOf("(");
					if (maxStart > -1) {
						String maxString = type.substring(maxStart + 1,
								type.length() - 1);
						if (!maxString.isEmpty()) {
							try {
								max = Long.valueOf(maxString);
								type = type.substring(0, maxStart);
							} catch (NumberFormatException e) {
								logger.log(Level.WARNING,
										"Failed to parse type max from type: "
												+ type, e);
							}
						}
					}
				}

				// Get the geometry or data type and default value
				int defaultValueIndex = result.getColumnIndex(DFLT_VALUE);

				TColumn column = createColumn(result, index, name, type, max,
						notNull, defaultValueIndex, primaryKey);
				columnList.add(column);
			}
		} finally {
			result.close();
		}
		if (columnList.isEmpty()) {
			throw new GeoPackageException("Table does not exist: " + tableName);
		}

		return createTable(tableName, columnList);
	}
94665
public long getLong(String columnName, long defaultValue) {
        int index = getColumnIndex(columnName);
        if (isValidIndex(index)) {
            return getLong(index);
        } else {
            return defaultValue;
        }
    }