/** * Converts them text align modes to a {@link Pos} element. * * @param aHorizAlignTextMode The horizontal portion to determine the according {@link Pos} element. * @param aVertAlignTextMode The vertical portion to determine the according {@link Pos} element. * * @return The accordingly determines {@link Pos} element. */ public static Pos toPos( HorizAlignTextMode aHorizAlignTextMode, VertAlignTextMode aVertAlignTextMode ) { for ( int i = 0; i < TEXT_ALIGN_MODE_TO_POS.length; i++ ) { if ( TEXT_ALIGN_MODE_TO_POS[i].vertAlignTextMode == aVertAlignTextMode && TEXT_ALIGN_MODE_TO_POS[i].horizAlignTextMode == aHorizAlignTextMode ) { return TEXT_ALIGN_MODE_TO_POS[i].pos; } } throw new BugException( "Missing <Pos> definition for combination <" + aHorizAlignTextMode + "> and <" + aVertAlignTextMode + "> in implementation!" ); }
/** * To bytes per int. * * @param aBitsPerDigit the bits per digit * @return the int */ protected static int toBytesPerInt( int aBitsPerDigit ) { for ( int i = (BYTES_PER_INT * BITS_PER_BYTE); i > 0; i-- ) { if ( i % aBitsPerDigit == 0 ) { return i / BITS_PER_BYTE; } } for ( int i = 1; i <= aBitsPerDigit; i++ ) { if ( i * BITS_PER_BYTE % aBitsPerDigit == 0 ) { return (i * BITS_PER_BYTE) / BITS_PER_BYTE; } } throw new BugException( "We must have encountered a bug as we cannot determine the word length for a base codec with <" + aBitsPerDigit + "> bits per digit." ); }
/** * {@inheritDoc} */ @Override default String toSerialized( char aDelimiter ) { ByteArrayOutputStream theOutputStream = new ByteArrayOutputStream(); try { saveTo( theOutputStream, aDelimiter ); theOutputStream.flush(); } catch ( IOException e ) { throw new BugException( "As the stream is created without any I/O merely in memory, we must never run into this: " + e.getMessage(), e ); } return theOutputStream.toString(); }
throw new BugException( "As the stream is created without any I/O merely in memory, we must never run into this: " + e.getMessage(), e );
break; default: throw new BugException( "Missing case statement for <" + this + "> in implementation!" );
throw new BugException( "Missing case statement for <" + this + "> in implementation!" );
/** * Registers a pre-configured {@link RestEndpoint} with the least required * attributes and returns its instance. To unsubscribe via * {@link #unsubscribeObserver(Object)}, use the returned instance. * * Attention: Invoke {@link RestEndpointBuilder#open()} to activate this * endpoint! * * @param aHttpMethod The HTTP-Method to which this {@link RestEndpoint} is * bound. A value of <code>null</code> means that any HTTP-Method may * trigger this {@link RestEndpoint}. * @param aLocatorPattern The local Locator-Pattern to which this * {@link RestEndpoint} is bound. A value of <code>null</code> means * that any locator may trigger this {@link RestEndpoint}. * @param aRequestObserver The listener processing a request targeted at * this {@link RestEndpoint}. * * @return The pre-configured {@link RestEndpoint} which acts as handle to * unsubscribe the {@link RestEndpoint} via * {@link #unsubscribeObserver(Object)}. */ default RestEndpointBuilder onRequest( HttpMethod aHttpMethod, String aLocatorPattern, RestRequestObserver aRequestObserver ) { RestEndpointBuilder theEndpoint = new RestEndpointBuilderImpl( aHttpMethod, aLocatorPattern, aRequestObserver ); if ( !subscribeObserver( theEndpoint ) ) { throw new BugException( "We encountered a bug! As we created the endpoint within this method, it cannot have been added already!" ); } return theEndpoint; }
/** * Calculates the size for the given {@link Font} in order to fit in the * given length (width or height). * * @param aFontName The name of the {@link Font} to be used. * @param aText The text for which to calculate the font size in order to * fit into the given length (width or height). * @param aLength The length (width or height, as of the {@link LayoutMode}) * in which the text with the newly calculated font-size is to fit. * @param aLayoutMode The mode to determine whether to use the width or the * height to calculate relative to. * * @return The calculated font-size to be used for the given {@link Font} in * order for the given text to fit into the provided length (width * or height). */ public static double toFontSize( String aFontName, String aText, double aLength, LayoutMode aLayoutMode ) { switch ( aLayoutMode ) { case HORIZONTAL: return toFontSizeWidth( aFontName, aText, aLength ); case VERTICAL: return toFontSizeHeight( aFontName, aText, aLength ); } throw new BugException( "Missing case statement for <" + aLayoutMode + "> in implementation!" ); }
return toBasicAuthFailure( aHttpExchange ); default: throw new BugException( "Missing case statement for <" + theBasicAuthResponse + "> in implementation!" );
break; default: throw new BugException( "Missing case statement for <" + getHttpExceptionHandling() + "> in implementation!" );
break; default: throw new BugException( "Missing case statement for <" + theOs + "> in implementation!" );
break; default: throw new BugException( "Missing case statement for <" + theOs + "> in implementation!" );