public static final String TEXT_ENCODING = "UTF-8";
- /* Macaco information */
+ /* Generic information. */
public static String getMacacoVersion() {
return MInformation.MACACO_VERSION;
return s.toString();
}
- /* Exceptions */
+ /* Exceptions. */
public static String getExceptionAsString(Exception exception) {
if (null == exception) {
return new MDateConverter(this.getDateFormats(), this.getLocale(), this.getTimeZone());
}
- /* Date formats */
+ /* Date formats. */
public void setDateFormats(LinkedHashSet<String> dateFormats) {
if (null == dateFormats) {
return this.getDateFormatsReference().iterator().next();
}
- /* Locale */
+ /* Locale. */
protected void setLocale(Locale locale) {
if (null == locale) {
return this.locale;
}
- /* Time zone */
+ /* Time zone. */
protected void setTimeZone(TimeZone timeZone) {
if (null == timeZone) {
return (TimeZone)this.getTimeZoneReference().clone();
}
- /* Conversion */
+ /* Conversions. */
protected static void checkDateFormat(String dateFormat) {
if (MText.isBlank(dateFormat)) {
return this.getStringFromDateByParameters(x, this.getDefaultDateFormat(), this.getLocale(), this.getTimeZoneReference());
}
- /* Helper methods */
+ /* Helpers. */
public static Date getFlatDate(Date x) {
if (null == x) {
return new MNumberConverter(this.getNumberFormats(), this.getLocale());
}
- /* Number formats */
+ /* Number formats. */
public void setNumberFormats(LinkedHashSet<String> numberFormats) {
if (null == numberFormats) {
return this.getNumberFormatsReference().iterator().next();
}
- /* Locale */
+ /* Locale. */
protected void setLocale(Locale locale) {
if (null == locale) {
return this.locale;
}
- /* Conversion */
+ /* Conversions. */
protected static void checkNumberFormat(String numberFormat) {
if (MText.isBlank(numberFormat)) {
return tmpMJsonArray;
}
- /* Values handlers */
+ /* Value handlers. */
public void addValue(MJsonValue x) {
if (null == x) {
this.getValuesReference().clear();
}
- /* Parsers */
+ /* Parsers. */
protected static int getTokenLength(String x) {
if (null == x) {
}
}
- /* Formatter */
+ /* Formatter. */
public String getJsonValue() {
StringBuilder s = new StringBuilder("");
return tmpMJsonBoolean;
}
- /* Value handlers */
+ /* Value handlers. */
public void setValue(Boolean x) {
if (null == x) {
return this.value;
}
- /* Parsers */
+ /* Parsers. */
protected static int getTokenLength(String x) {
if (null == x) {
this.setValue(Boolean.valueOf(x));
}
- /* Formatter */
+ /* Formatter. */
public String getJsonValue() {
return this.getValue().toString();
return tmpMJsonNull;
}
- /* Parsers */
+ /* Parsers. */
protected static int getTokenLength(String x) {
if (null == x) {
}
}
- /* Formatter */
+ /* Formatter. */
public String getJsonValue() {
return "null";
return tmpMJsonNumber;
}
- /* Value handlers */
+ /* Value handlers. */
public void setValue(Number x) {
if (null == x) {
return this.value;
}
- /* Parsers */
+ /* Parsers. */
protected static int getTokenLength(String x) {
if (null == x) {
this.setValue(y);
}
- /* Formatter */
+ /* Formatter. */
public String getJsonValue() {
return this.getValue().toString();
return tmpMJsonObject;
}
- /* Values handlers */
+ /* Value handlers. */
public void setValue(String key, MJsonValue x) {
if (MText.isBlank(key)) {
return keys;
}
- /* Parsers */
+ /* Parsers. */
protected static int getTokenLength(String x) {
if (null == x) {
}
}
- /* Formatter */
+ /* Formatter. */
public String getJsonValue() {
StringBuilder s = new StringBuilder("");
return tmpMJsonString;
}
- /* Extended escape mode */
+ /* Extended escape mode. */
public void setExtendedEscapeMode(boolean extendedEscapeMode) {
this.extendedEscapeMode = extendedEscapeMode;
return this.extendedEscapeMode;
}
- /* Value handlers */
+ /* Value handlers. */
public void setValue(String x) {
if (null == x) {
return this.value;
}
- /* Helpers */
+ /* Helpers. */
protected static String getEscapedString(String x, boolean extendedEscapeMode) {
if (null == x) {
return y.toString();
}
- /* Parsers */
+ /* Parsers. */
protected static int getTokenLength(String x) {
if (null == x) {
this.setValue(MJsonString.getUnescapedString(y));
}
- /* Formatter */
+ /* Formatter. */
public String getJsonValue() {
return "\"" + MJsonString.getEscapedString(this.getValue(), this.getExtendedEscapeMode()) + "\"";
public abstract MJsonValue clone();
- /* Helpers */
+ /* Helpers. */
protected static boolean isWhitespace(int c) {
return ((' ' == c) || ('\t' == c) || ('\n' == c) || ('\r' == c));
return ((']' == c) || ('}' == c));
}
- /* Formatter */
+ /* Formatter. */
public abstract String getJsonValue();
}
}
- /* Sql connection generator */
+ /* Sql connection generator. */
protected MSqlConnectionGenerator getSqlConnectionGeneratorReference() {
return this.sqlConnectionGenerator;
}
- /* Logging database parameters */
+ /* Database logging parameters. */
protected String getLogDatabaseTable() {
return this.logDatabaseTable;
return this.logDatabaseField;
}
- /* Sql connection */
+ /* Sql connection. */
protected MSqlConnection getSqlConnectionReference() {
return this.sqlConnection;
}
- /* Output */
+ /* Output. */
public void appendMessage(String message) throws MLoggingException {
this.appendMessage(message, 0);
}
}
- /* Threshold */
+ /* Threshold. */
public void setThreshold(MLogFilter.Threshold threshold) {
if (null == threshold) {
return this.threshold;
}
- /* Log targets */
+ /* Log targets. */
public void addLogTarget(MLogTarget logTarget) {
if (null == logTarget) {
return this.logTargets;
}
- /* Output */
+ /* Output. */
public void setPausedState(boolean pausedState) throws MLoggingException {
this.pausedState = pausedState;
this.indentation = indentation;
}
- /* Values */
+ /* Values. */
public String getMessage() {
return this.message;
}
}
- /* File */
+ /* File. */
protected String getFile() {
return this.file;
}
- /* Buffer */
+ /* Buffer. */
protected BufferedWriter getBufferReference() {
return this.buffer;
}
- /* Output */
+ /* Output. */
public void appendMessage(String message) throws MLoggingException {
this.appendMessage(message, 0);
}
}
- /* Output */
+ /* Output. */
public abstract void appendMessage(String message) throws MLoggingException;
this.url = url;
this.username = username;
this.password = password;
- // load driver
+ // Load driver.
try {
Class.forName(this.getDriver()).newInstance();
}
catch (InstantiationException exception) {
throw new MSqlConnectionFailureException("Could not load driver.", exception);
}
- // establish connection
+ // Establish a connection.
try {
this.connection = DriverManager.getConnection(this.getUrl(), this.getUsername(), this.getPassword());
}
catch (SQLException exception) {
throw new MSqlConnectionFailureException("Could not get connection.", exception);
}
- // set SQL mode
+ // Set SQL mode to standard ANSI.
try {
this.getConnectionReference().createStatement().executeUpdate("SET SQL_MODE='ANSI'");
}
}
}
- /* Driver */
+ /* Driver. */
public String getDriver() {
return this.driver;
}
- /* Url */
+ /* Url. */
public String getUrl() {
return this.url;
}
- /* Username */
+ /* Username. */
public String getUsername() {
return this.username;
}
- /* Password */
+ /* Password. */
public String getPassword() {
return this.password;
}
- /* Connection */
+ /* Connection. */
protected Connection getConnectionReference() {
return this.connection;
}
- /* Transactions */
+ /* Transactions. */
protected void setTransactionStatus(MSqlConnection.TransactionStatus transactionStatus) {
if (null == transactionStatus) {
}
}
- /* Statements */
+ /* Statements. */
public MSqlStatementResults executePreparedStatement(String statement) throws MSqlStatementException {
return this.executePreparedStatement(statement, new LinkedList<Object>());
MSqlStatementResults results = null;
PreparedStatement preparedStatement = null;
try {
- // prepare the statement
+ // Prepare the statement.
preparedStatement = this.getConnectionReference().prepareStatement(statement, PreparedStatement.RETURN_GENERATED_KEYS);
for (int p = 0; parameters.size() > p; p++) {
preparedStatement.setObject(p + 1, parameters.get(p));
}
- // execute the statement and parse the results
+ // Execute the statement and parse the results.
preparedStatement.execute();
results = new MSqlStatementResults(preparedStatement);
}
return results;
}
- /* Tables */
+ /* Tables. */
public MSqlTable getTable(String table, String primaryKey) {
return new MSqlTable(this, table, primaryKey);
this.password = password;
}
- /* Driver */
+ /* Driver. */
public String getDriver() {
return this.driver;
}
- /* Url */
+ /* Url. */
public String getUrl() {
return this.url;
}
- /* Username */
+ /* Username. */
public String getUsername() {
return this.username;
}
- /* Password */
+ /* Password. */
public String getPassword() {
return this.password;
}
- /* Generator */
+ /* Generator. */
public MSqlConnection getConnection() throws MSqlConnectionFailureException {
return new MSqlConnection(this.getDriver(), this.getUrl(), this.getUsername(), this.getPassword());
this.initializeConnectionPool();
}
- /* Connection generator */
+ /* Connection generator. */
protected MSqlConnectionGenerator getConnectionGenerator() {
return this.connectionGenerator;
}
- /* Connection pool */
+ /* Connection pool. */
protected int getMinimumSize() {
return this.minimumSize;
}
}
- /* References */
+ /* References. */
protected PreparedStatement getPreparedStatementReference() {
return this.preparedStatement;
return this.resultSet;
}
- /* Records */
+ /* Records. */
protected LinkedList<LinkedHashMap<String, Object>> getRecordsReference() {
return this.records;
return recordsByField;
}
- /* Generated keys */
+ /* Generated keys. */
protected LinkedHashSet<Object> getGeneratedKeysReference() {
return this.generatedKeys;
this.primaryKey = primaryKey;
}
- /* Connection */
+ /* Connection. */
protected MSqlConnection getConnectionReference() {
return this.connection;
}
- /* Table */
+ /* Table. */
public String getTable() {
return this.table;
}
- /* Primary key */
+ /* Primary key. */
public String getPrimaryKey() {
return this.primaryKey;
}
- /* Statements */
+ /* Statements. */
protected MSqlStatementResults insertRecord(LinkedHashMap<String, Object> map) throws MSqlStatementException {
if (null == map) {
public class MText extends MObject {
- /* Checks */
+ /* Checks. */
public static boolean isEmpty(String x) {
if ((null != x) && ("".equals(x))) {
return false;
}
- /* Utility methods */
+ /* Utility methods. */
public static String repeat(String x, int times) {
if (1 > times) {
return y.toString();
}
- /* Javascript escape */
+ /* Javascript escape. */
public static String getJavascriptEscapedString(String x) {
if (null == x) {
return text;
}
- /* Xhtml escape and safety */
+ /* Xhtml escape and safety. */
public static String getXhtmlEscapedString(String x) { // similar to PHP's htmlspecialchars()
if (null == x) {
fakeXhtmlPageContent.append("<head><title /></head>");
fakeXhtmlPageContent.append(String.format("<body>%s</body>", text));
fakeXhtmlPageContent.append("</html>");
- // validate Xhtml (without dangerous tags and event attributes)
+ // Validate Xhtml (with no dangerous tags and event attributes).
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(true);
}
catch (IOException exception) { // cannot happen; put here not to bypass UnsupportedEncodingException
}
- // also convert named entities to numeric entities
+ // Also convert named entities to numeric entities.
return MText.getXhtmlNumericEntitiesString(text);
}
return tmpMTranslator;
}
- /* File */
+ /* File. */
protected String getFile() {
return this.file;
}
- /* Locale */
+ /* Locale. */
protected Locale getBasicLocale() {
return this.basicLocale;
}
- /* Strings management */
+ /* String management. */
protected LinkedHashMap<String, LinkedHashMap<String, String>> getMessagesReference() {
return this.messages;