/** * Sets the {@link Boolean} value for the property referred to by the * key. As property keys and values are of type {@link String}, the * {@link Boolean} value is converted accordingly. * * @param aKey The key for which to retrieve the value. * @param aValue The {@link Boolean} representation for the * {@link String} value. * @return the string */ default String putBoolean( String aKey, Boolean aValue ) { return put( aKey, Boolean.TRUE.equals( aValue ) ? Literal.TRUE.getName() : Literal.FALSE.getName() ); }
/** * Determines whether the value of a {@link CriteriaLeaf} is NULL. * * @param aCriteriaLeaf The {@link CriteriaLeaf} to be tested. * * @return True in case a NULL value us being detected. */ private boolean isNullCriteriaLeaf( CriteriaLeaf<?> aCriteriaLeaf ) { return ((aCriteriaLeaf.getValue() instanceof String) && ((String) aCriteriaLeaf.getValue()).equalsIgnoreCase( Literal.NULL.getName() )); } }
if ( !Literal.NULL.getName().equals( theValue ) ) {
/** * Determines the computer's name. First it tries to get it from the * {@link InetAddress}, if it fails it tries to get it from the system's * environment using the {@link EnvironmentVariable#COMPUTERNAME} (on * Windows machines only) and if both fails, it returns the default * {@link Literal#LOCALHOST} identifier. * * @return The computer's name, as fallback, {@link Literal#LOCALHOST} * ("localhost") is returned. */ public static String getComputerName() { try { return InetAddress.getLocalHost().getHostName(); } catch ( UnknownHostException e ) { String theName = EnvironmentVariable.COMPUTERNAME.getValue(); if ( theName == null || theName.length() == 0 ) { theName = EnvironmentVariable.HOSTNAME.getValue(); } if ( theName != null && theName.length() > 0 ) { return theName; } } return Literal.LOCALHOST.getName(); }
/** * Generates a query string for the given {@link CriteriaLeaf}. * * @param aCriteriaLeaf The {@link CriteriaLeaf} for which to generate the * query. * * @param isCriteriaTreeRoot True in case the {@link CriteriaLeaf} is the * root of the {@link Criteria} tree. Being root means dedicated * handling of the {@link CriteriaLeaf} then not being root. * * @return The query generated from the given {@link CriteriaLeaf}. */ private String toQuery( EqualWithCriteria<?> aCriteriaLeaf, boolean isCriteriaTreeRoot ) { StringBuffer theQueryBuffer = new StringBuffer(); if ( !isCriteriaTreeRoot ) { theQueryBuffer.append( BRACE_OPEN ); } theQueryBuffer.append( aCriteriaLeaf.getKey() ); if ( Literal.NULL.getName().equalsIgnoreCase( aCriteriaLeaf.getValue().toString() ) ) { theQueryBuffer.append( IS ); } else { theQueryBuffer.append( EQUAL_WITH ); } doAppendCriteriaLeaf( aCriteriaLeaf, theQueryBuffer ); if ( !isCriteriaTreeRoot ) { theQueryBuffer.append( BRACE_CLOSE ); } return theQueryBuffer.toString(); }
/** * Appends a {@link CriteriaLeaf} to the provided {@link StringBuffer}. * * @param aCriteriaLeaf The {@link CriteriaLeaf} to be append. * @param aQueryBuffer The {@link StringBuffer} to which to append. */ private void doAppendCriteriaLeaf( CriteriaLeaf<?> aCriteriaLeaf, StringBuffer aQueryBuffer ) { boolean isQuote = (!(aCriteriaLeaf.getValue() instanceof Number)) && (!isNullCriteriaLeaf( aCriteriaLeaf )); if ( isQuote ) { aQueryBuffer.append( SINGLE_QUOTE ); } if ( isNullCriteriaLeaf( aCriteriaLeaf ) ) { aQueryBuffer.append( Literal.NULL.getName().toUpperCase() ); } else { aQueryBuffer.append( aCriteriaLeaf.getValue() ); } if ( isQuote ) { aQueryBuffer.append( SINGLE_QUOTE ); } }
if ( !Literal.NULL.getName().equals( eToValue ) ) {
/** * Heuristically loads the arguments without any syntax required, e.g. * without any root {@link Condition} to be set. * * @param aArgs The arguments to be loaded. * @param aDelimiter The delimiter to resolve name clashes. * @return A list of heuristically determined {@link Flag} and * {@link StringOperandImpl} instances. */ protected static List<? extends Operand<?>> fromArgs( String[] aArgs, char aDelimiter ) { List<Operand<?>> theOperands = new ArrayList<>(); Map<String, String> theArgs = RuntimeUtility.toProperties( aArgs, CommandArgPrefix.toPrefixes(), aDelimiter ); for ( String eKey : theArgs.keySet() ) { if ( Literal.TRUE.getName().equalsIgnoreCase( theArgs.get( eKey ) ) ) { theOperands.add( new FlagImpl( eKey, true ) ); } else { theOperands.add( new StringOperandImpl( new PropertyImpl( eKey, theArgs.get( eKey ) ) ) ); } } return theOperands; }
if ( !Literal.NULL.getName().equals( theToValue ) ) {
if ( !Literal.NULL.getName().equals( theToValue ) ) {
/** * Returns a {@link String} with all Correlation-IDs found separated by a * {@link Delimiter#CORRELATION_ID} character from each other. Any portion * of the full Correlation-ID not being set is represented by a "<?>" * sequence defined by {@link Literal#UNKNOWN}. * * @return The full Correlation-ID. */ public static String toFullCorrelationId() { String theFullCorrelationId = ""; String eId; Correlation[] correlations = values(); for ( int i = correlations.length - 1; i >= 0; i-- ) { if ( theFullCorrelationId.length() != 0 ) theFullCorrelationId += Delimiter.CORRELATION_ID.getChar(); eId = correlations[i].getId(); if ( eId == null ) eId = Literal.UNKNOWN.getName(); theFullCorrelationId += eId; } return theFullCorrelationId; }
putProperty( theBuilder, eOption, Literal.TRUE.getName(), aDelimiter ); eOption = eNextOption; if ( i == aArgs.length - 1 ) { putProperty( theBuilder, eOption, Literal.TRUE.getName(), aDelimiter ); eOption = eNextOption; if ( i == aArgs.length - 1 ) { putProperty( theBuilder, eOption, Literal.TRUE.getName(), aDelimiter );
theUrl.setHost( Literal.LOCALHOST.getName() );