}
}
- protected LinkedHashSet<String> getDateFormatsReference() {
- return this.dateFormats;
- }
-
public LinkedHashSet<String> getDateFormats() {
- LinkedHashSet<String> tmpDateFormats = new LinkedHashSet<String>();
- Iterator i = this.getDateFormatsReference().iterator();
- while (i.hasNext()) {
- tmpDateFormats.add((String)i.next());
- }
- return tmpDateFormats;
+ return this.dateFormats;
}
public String getDefaultDateFormat() {
- return this.getDateFormatsReference().iterator().next();
+ return this.getDateFormats().iterator().next();
}
/* Locale. */
this.timeZone = timeZone;
}
- protected TimeZone getTimeZoneReference() {
- return this.timeZone;
- }
-
public TimeZone getTimeZone() {
- return (TimeZone)this.getTimeZoneReference().clone();
+ return this.timeZone;
}
/* Conversions. */
public Date getDateFromString(String x) throws MInvalidConversionFormatException {
Date y = null;
- for (String dateFormat: this.getDateFormatsReference()) {
+ for (String dateFormat: this.getDateFormats()) {
try {
- y = this.getDateFromStringByParameters(x, dateFormat, this.getLocale(), this.getTimeZoneReference());
+ y = this.getDateFromStringByParameters(x, dateFormat, this.getLocale(), this.getTimeZone());
return y;
}
catch (MInvalidConversionFormatException exception) {
}
public String getStringFromDate(Date x) {
- return this.getStringFromDateByParameters(x, this.getDefaultDateFormat(), this.getLocale(), this.getTimeZoneReference());
+ return this.getStringFromDateByParameters(x, this.getDefaultDateFormat(), this.getLocale(), this.getTimeZone());
}
/* Helpers. */
}
}
- protected LinkedHashSet<String> getNumberFormatsReference() {
- return this.numberFormats;
- }
-
public LinkedHashSet<String> getNumberFormats() {
- LinkedHashSet<String> tmpNumberFormats = new LinkedHashSet<String>();
- Iterator i = this.getNumberFormatsReference().iterator();
- while (i.hasNext()) {
- tmpNumberFormats.add((String)i.next());
- }
- return tmpNumberFormats;
+ return this.numberFormats;
}
public String getDefaultNumberFormat() {
- return this.getNumberFormatsReference().iterator().next();
+ return this.getNumberFormats().iterator().next();
}
/* Locale. */
public BigDecimal getNumberFromString(String x) throws MInvalidConversionFormatException {
BigDecimal y = null;
- for (String numberFormat: this.getNumberFormatsReference()) {
+ for (String numberFormat: this.getNumberFormats()) {
try {
y = this.getNumberFromStringByParameters(x, numberFormat, this.getLocale());
return y;
throw new IllegalArgumentException("Invalid 'x': null.");
}
//
- this.getValuesReference().add(x);
+ this.getValues().add(x);
}
public void setValue(int index, MJsonValue x) {
throw new IllegalArgumentException("Invalid 'x': null.");
}
//
- this.getValuesReference().set(index, x);
+ this.getValues().set(index, x);
}
- protected LinkedList<MJsonValue> getValuesReference() {
+ protected LinkedList<MJsonValue> getValues() {
return this.values;
}
throw new IllegalArgumentException(String.format("Invalid 'index': %s: out of range.", index));
}
//
- return this.getValuesReference().get(index).clone();
+ return this.getValues().get(index).clone();
}
public int getValueCount() {
- return this.getValuesReference().size();
+ return this.getValues().size();
}
public void removeValue(int index) {
throw new IllegalArgumentException(String.format("Invalid 'index': %s: out of range.", index));
}
//
- this.getValuesReference().remove(index);
+ this.getValues().remove(index);
}
public void clearValues() {
- this.getValuesReference().clear();
+ this.getValues().clear();
}
/* Parsers. */
if (0 < i) {
s.append(", ");
}
- s.append(this.getValuesReference().get(i).getJsonValue());
+ s.append(this.getValues().get(i).getJsonValue());
}
s.append("]");
return s.toString();
throw new IllegalArgumentException("Invalid 'x': null.");
}
//
- this.getValuesReference().put(key, x);
+ this.getValues().put(key, x);
}
- protected LinkedHashMap<String, MJsonValue> getValuesReference() {
+ protected LinkedHashMap<String, MJsonValue> getValues() {
return this.values;
}
if (!this.containsKey(key)) {
throw new IllegalArgumentException(String.format("Invalid 'key': %s: not available.", key));
}
- return this.getValuesReference().get(key).clone();
+ return this.getValues().get(key).clone();
}
public int getValueCount() {
- return this.getValuesReference().size();
+ return this.getValues().size();
}
public void removeValue(String key) {
if (!this.containsKey(key)) {
throw new IllegalArgumentException(String.format("Invalid 'key': %s: not available.", key));
}
- this.getValuesReference().remove(key);
+ this.getValues().remove(key);
}
public void clearValues() {
- this.getValuesReference().clear();
+ this.getValues().clear();
}
public boolean containsKey(String key) {
throw new IllegalArgumentException("Invalid 'key': null or empty.");
}
//
- return this.getValuesReference().containsKey(key);
+ return this.getValues().containsKey(key);
}
public LinkedHashSet<String> getKeys() {
LinkedHashSet<String> keys = new LinkedHashSet<String>();
- for (String key: this.getValuesReference().keySet()) {
+ for (String key: this.getValues().keySet()) {
keys.add(key);
}
return keys;
StringBuilder s = new StringBuilder("");
s.append("{");
int k = 0;
- for (String key: this.getValuesReference().keySet()) {
+ for (String key: this.getValues().keySet()) {
if (0 < k) {
s.append(", ");
}
s.append("\"" + MJsonString.getEscapedString(key, false) + "\"");
s.append(": ");
- s.append(this.getValuesReference().get(key).getJsonValue());
+ s.append(this.getValues().get(key).getJsonValue());
k++;
}
s.append("}");
public void close() throws MLoggingException {
try {
- this.getSqlConnectionReference().close();
+ this.getSqlConnection().close();
}
catch (MSqlConnectionFailureException exception) {
throw new MLoggingException("Could not close Sql connection.", exception);
/* Sql connection generator. */
- protected MSqlConnectionGenerator getSqlConnectionGeneratorReference() {
+ protected MSqlConnectionGenerator getSqlConnectionGenerator() {
return this.sqlConnectionGenerator;
}
/* Sql connection. */
- protected MSqlConnection getSqlConnectionReference() {
+ protected MSqlConnection getSqlConnection() {
return this.sqlConnection;
}
separator.append(" ");
}
//
- if (null == this.getSqlConnectionReference()) {
- this.sqlConnection = this.getSqlConnectionGeneratorReference().getNewConnection();
+ if (null == this.getSqlConnection()) {
+ this.sqlConnection = this.getSqlConnectionGenerator().getNewConnection();
}
//
LinkedHashMap<String, Object> p = new LinkedHashMap<String, Object>();
p.put(this.getLogDatabaseField(), timestamp + separator + message);
- (new MSqlTable(this.getSqlConnectionReference(), this.getLogDatabaseTable(), this.getLogDatabaseTablePrimaryKey())).setRecord(p, null);
+ (new MSqlTable(this.getSqlConnection(), this.getLogDatabaseTable(), this.getLogDatabaseTablePrimaryKey())).setRecord(p, null);
}
catch (MSqlConnectionFailureException exception) {
throw new MLoggingException("Could not write to database table.", exception);
}
public void close() throws MLoggingException {
- for (MLogTarget t: this.getLogTargetsReference()) {
+ for (MLogTarget t: this.getLogTargets()) {
t.close();
}
}
}
}
- protected LinkedList<MLogTarget> getLogTargetsReference() {
+ protected LinkedList<MLogTarget> getLogTargets() {
return this.logTargets;
}
String message = logMessage.getMessage();
int indentation = logMessage.getIndentation();
//
- for (MLogTarget logTarget: this.getLogTargetsReference()) {
+ for (MLogTarget logTarget: this.getLogTargets()) {
logTarget.appendMessage(message, indentation);
}
}
public void close() throws MLoggingException {
try {
- this.getBufferReference().close();
+ this.getBuffer().close();
}
catch (IOException exception) {
throw new MLoggingException("Could not close file.", exception);
/* Buffer. */
- protected BufferedWriter getBufferReference() {
+ protected BufferedWriter getBuffer() {
return this.buffer;
}
separator.append(" ");
}
//
- synchronized (this.getBufferReference()) {
- this.getBufferReference().write(timestamp + separator + message);
- this.getBufferReference().newLine();
- this.getBufferReference().flush();
+ synchronized (this.getBuffer()) {
+ this.getBuffer().write(timestamp + separator + message);
+ this.getBuffer().newLine();
+ this.getBuffer().flush();
}
}
catch (IOException exception) {
}
// Set SQL mode to standard ANSI.
try {
- this.getConnectionReference().createStatement().executeUpdate("SET SQL_MODE='ANSI'");
+ this.getConnection().createStatement().executeUpdate("SET SQL_MODE='ANSI'");
}
catch (SQLException exception) {
throw new MSqlConnectionFailureException("Could not set SQL mode to ANSI.", exception);
public void close() throws MSqlConnectionFailureException {
try {
- this.getConnectionReference().close();
+ this.getConnection().close();
}
catch (SQLException exception) {
throw new MSqlConnectionFailureException("Could not close connection.", exception);
public boolean isClosed() throws MSqlConnectionFailureException {
try {
- return this.getConnectionReference().isClosed();
+ return this.getConnection().isClosed();
}
catch (SQLException exception) {
throw new MSqlConnectionFailureException("Could not determine the state.", exception);
/* Connection. */
- protected Connection getConnectionReference() {
+ protected Connection getConnection() {
return this.connection;
}
throw new MSqlTransactionException("Nested transactions not allowed.");
}
try {
- this.getConnectionReference().setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
- this.getConnectionReference().setAutoCommit(false);
+ this.getConnection().setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+ this.getConnection().setAutoCommit(false);
this.setTransactionStatus(MSqlConnection.TransactionStatus.SUCCESSFUL);
}
catch (SQLException exception) {
throw new MSqlTransactionException("Transaction not started.");
}
try {
- this.getConnectionReference().rollback();
- this.getConnectionReference().setAutoCommit(true);
+ this.getConnection().rollback();
+ this.getConnection().setAutoCommit(true);
this.setTransactionStatus(MSqlConnection.TransactionStatus.CLOSED);
}
catch (SQLException exception) {
switch (this.getTransactionStatus()) {
case SUCCESSFUL:
try {
- this.getConnectionReference().commit();
- this.getConnectionReference().setAutoCommit(true);
+ this.getConnection().commit();
+ this.getConnection().setAutoCommit(true);
this.setTransactionStatus(MSqlConnection.TransactionStatus.CLOSED);
return MSqlConnection.TransactionStatus.SUCCESSFUL;
}
PreparedStatement preparedStatement = null;
try {
// Prepare the statement.
- preparedStatement = this.getConnectionReference().prepareStatement(statement, PreparedStatement.RETURN_GENERATED_KEYS);
+ preparedStatement = this.getConnection().prepareStatement(statement, PreparedStatement.RETURN_GENERATED_KEYS);
for (int p = 0; parameters.size() > p; p++) {
preparedStatement.setObject(p + 1, parameters.get(p));
}
this.preparedStatement = preparedStatement;
//
try {
- this.resultSet = this.getPreparedStatementReference().getResultSet();
- if (null != this.getResultSetReference()) {
- while (this.getResultSetReference().next()) {
- ResultSetMetaData resultSetMetaData = this.getResultSetReference().getMetaData();
+ this.resultSet = this.getPreparedStatement().getResultSet();
+ if (null != this.getResultSet()) {
+ while (this.getResultSet().next()) {
+ ResultSetMetaData resultSetMetaData = this.getResultSet().getMetaData();
LinkedHashMap<String, Object> record = new LinkedHashMap<String, Object>();
for (int f = 0; resultSetMetaData.getColumnCount() > f; f++) {
String field = resultSetMetaData.getColumnLabel(f + 1);
- record.put(field, this.getResultSetReference().getObject(field));
+ record.put(field, this.getResultSet().getObject(field));
}
- this.getRecordsReference().add(record);
+ this.getRecords().add(record);
}
}
}
}
//
try {
- ResultSet generatedKeysResultSet = this.getPreparedStatementReference().getGeneratedKeys();
+ ResultSet generatedKeysResultSet = this.getPreparedStatement().getGeneratedKeys();
while (generatedKeysResultSet.next()) {
- this.getGeneratedKeysReference().add(generatedKeysResultSet.getObject(1));
+ this.getGeneratedKeys().add(generatedKeysResultSet.getObject(1));
}
generatedKeysResultSet.close();
}
public void close() throws MSqlConnectionFailureException {
try {
- if (null != this.getResultSetReference()) {
- this.getResultSetReference().close();
+ if (null != this.getResultSet()) {
+ this.getResultSet().close();
}
- this.getPreparedStatementReference().close();
+ this.getPreparedStatement().close();
}
catch (SQLException exception) {
throw new MSqlConnectionFailureException("Could not close statement and/or result set references.", exception);
/* References. */
- protected PreparedStatement getPreparedStatementReference() {
+ protected PreparedStatement getPreparedStatement() {
return this.preparedStatement;
}
- public ResultSet getResultSetReference() {
+ public ResultSet getResultSet() {
return this.resultSet;
}
/* Records. */
- protected LinkedList<LinkedHashMap<String, Object>> getRecordsReference() {
- return this.records;
- }
-
public LinkedList<LinkedHashMap<String, Object>> getRecords() {
- LinkedList<LinkedHashMap<String, Object>> tmpRecords = new LinkedList<LinkedHashMap<String, Object>>();
- for (LinkedHashMap<String, Object> record: this.getRecordsReference()) {
- LinkedHashMap<String, Object> tmpRecord = new LinkedHashMap<String, Object>();
- for (String key: record.keySet()) {
- tmpRecord.put(key, record.get(key));
- }
- tmpRecords.add(tmpRecord);
- }
- return tmpRecords;
+ return this.records;
}
public LinkedList<Object> getRecordsByField(String field) {
}
//
LinkedList<Object> recordsByField = new LinkedList<Object>();
- for (LinkedHashMap<String, Object> record: this.getRecordsReference()) {
+ for (LinkedHashMap<String, Object> record: this.getRecords()) {
Object r = record.get(field);
if (null == r) {
throw new IllegalArgumentException(String.format("Invalid 'field': %s.", field));
/* Generated keys. */
- protected LinkedHashSet<Object> getGeneratedKeysReference() {
- return this.generatedKeys;
- }
-
public LinkedHashSet<Object> getGeneratedKeys() {
- LinkedHashSet<Object> tmpGeneratedKeys = new LinkedHashSet<Object>();
- Iterator i = this.getGeneratedKeysReference().iterator();
- while (i.hasNext()) {
- tmpGeneratedKeys.add(i.next());
- }
- return tmpGeneratedKeys;
+ return this.generatedKeys;
}
}
/* Connection. */
- protected MSqlConnection getConnectionReference() {
+ protected MSqlConnection getConnection() {
return this.connection;
}
}
fields.delete(fields.length() - 2, fields.length());
s.delete(s.length() - 2, s.length());
- return this.getConnectionReference().executePreparedStatement(" INSERT INTO \"" + this.getTable() + "\""
- + " (" + fields + ")"
- + " VALUES (" + s + ")",
- p);
+ return this.getConnection().executePreparedStatement(" INSERT INTO \"" + this.getTable() + "\""
+ + " (" + fields + ")"
+ + " VALUES (" + s + ")",
+ p);
}
protected MSqlStatementResults updateRecord(LinkedHashMap<String, Object> map, Object id) throws MSqlStatementException {
}
s.delete(s.length() - 2, s.length());
p.add(id);
- return this.getConnectionReference().executePreparedStatement(" UPDATE \"" + this.getTable() + "\""
- + " SET " + s
- + " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
- p);
+ return this.getConnection().executePreparedStatement(" UPDATE \"" + this.getTable() + "\""
+ + " SET " + s
+ + " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
+ p);
}
public MSqlStatementResults setRecord(LinkedHashMap<String, Object> map, Object id) throws MSqlStatementException {
//
LinkedList<Object> p = new LinkedList<Object>();
p.add(id);
- return this.getConnectionReference().executePreparedStatement(" SELECT *"
- + " FROM \"" + this.getTable() + "\""
- + " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
- p);
+ return this.getConnection().executePreparedStatement(" SELECT *"
+ + " FROM \"" + this.getTable() + "\""
+ + " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
+ p);
}
public MSqlStatementResults deleteRecord(Object id) throws MSqlStatementException {
//
LinkedList<Object> p = new LinkedList<Object>();
p.add(id);
- return this.getConnectionReference().executePreparedStatement(" DELETE FROM \"" + this.getTable() + "\""
- + " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
- p);
+ return this.getConnection().executePreparedStatement(" DELETE FROM \"" + this.getTable() + "\""
+ + " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
+ p);
}
public MSqlStatementResults deleteRecords(LinkedHashSet idSet) throws MSqlStatementException {
whereClause.append(" OR (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)");
p.add(id);
}
- return this.getConnectionReference().executePreparedStatement(" DELETE FROM \"" + this.getTable() + "\""
- + " WHERE (" + whereClause + ")",
- p);
+ return this.getConnection().executePreparedStatement(" DELETE FROM \"" + this.getTable() + "\""
+ + " WHERE (" + whereClause + ")",
+ p);
}
}
/* String management. */
- protected LinkedHashMap<String, LinkedHashMap<String, String>> getMessagesReference() {
+ protected LinkedHashMap<String, LinkedHashMap<String, String>> getMessages() {
return this.messages;
}
}
String message = null;
String line = null;
- synchronized (this.getMessagesReference()) {
+ synchronized (this.getMessages()) {
while (true) {
try {
line = buffer.readLine();
}
else if (null == message) {
message = line;
- if (this.getMessagesReference().containsKey(message)) {
+ if (this.getMessages().containsKey(message)) {
throw new MTranslationFileParsingException(String.format("Invalid line: %s: duplicated message: %s.", buffer.getLineNumber(), message));
}
- this.getMessagesReference().put(message, new LinkedHashMap<String, String>());
+ this.getMessages().put(message, new LinkedHashMap<String, String>());
}
else {
int a = line.indexOf("=");
}
String localeRepresentation = line.substring(0, a).trim();
String translation = line.substring(a + 1).trim();
- if (this.getMessagesReference().get(message).containsKey(localeRepresentation)) {
+ if (this.getMessages().get(message).containsKey(localeRepresentation)) {
throw new MTranslationFileParsingException(String.format("Invalid line: %s: duplicated translation for locale: %s.", buffer.getLineNumber(), message));
}
- this.getMessagesReference().get(message).put(localeRepresentation, translation);
+ this.getMessages().get(message).put(localeRepresentation, translation);
}
}
}
}
public void clear() {
- synchronized (this.getMessagesReference()) {
- this.getMessagesReference().clear();
+ synchronized (this.getMessages()) {
+ this.getMessages().clear();
}
}
throw new IllegalArgumentException("Invalid 'locale': null.");
}
//
- if (!this.getMessagesReference().containsKey(message)) {
+ if (!this.getMessages().containsKey(message)) {
if (strictMode) {
throw new MTranslationValueNotFoundException(String.format("Invalid 'message': %s: not available.", message));
}
if (this.getBasicLocale().equals(locale)) {
return message;
}
- LinkedHashMap<String, String> messageTranslations = this.getMessagesReference().get(message);
+ LinkedHashMap<String, String> messageTranslations = this.getMessages().get(message);
String localeRepresentation = locale.toString();
if (!messageTranslations.containsKey(localeRepresentation)) {
if (strictMode) {