protected List < IAlias > loadAliases ( Scriptable cfg ) throws IOException { Object aliasList = cfg . get ( ALIASES_CONFIGPARAM , cfg ) ; List < IAlias > aliases = new LinkedList < IAlias > ( ) ; if ( aliasList instanceof Scriptable ) { for ( Object id : ( ( Scriptable ) aliasList ) . getIds ( ) ) { if ( id instanceof Number ) { Number i = ( Number ) id ; Object entry = ( ( Scriptable ) aliasList ) . get ( ( Integer ) i , ( Scriptable ) aliasList ) ; if ( entry instanceof Scriptable ) { Scriptable vec = ( Scriptable ) entry ; Object pattern = vec . get ( 0 , vec ) ; Object replacement = vec . get ( 1 , vec ) ; if ( pattern == Scriptable . NOT_FOUND || replacement == Scriptable . NOT_FOUND ) { throw new IllegalArgumentException ( toString ( entry ) ) ; } if ( pattern instanceof Scriptable && "RegExp" . equals ( ( ( Scriptable ) pattern ) . getClassName ( ) ) ) { //$NON-NLS-1$ String regexlit = toString ( pattern ) ; String regex = regexlit . substring ( 1 , regexlit . lastIndexOf ( "/" ) ) ; //$NON-NLS-1$ String flags = regexlit . substring ( regexlit . lastIndexOf ( "/" ) + 1 ) ; //$NON-NLS-1$ int options = 0 ; if ( flags . contains ( "i" ) ) { //$NON-NLS-1$ options |= Pattern . CASE_INSENSITIVE ; } pattern = Pattern . compile ( regex , options ) ; } else { pattern = toString ( pattern ) ; } if ( ! ( replacement instanceof Scriptable ) || ! "Function" . equals ( ( ( Scriptable ) replacement ) . getClassName ( ) ) ) { //$NON-NLS-1$ replacement = toString ( replacement ) ; } aliases . add ( newAlias ( pattern , replacement ) ) ; } else { throw new IllegalArgumentException ( Context . toString ( ALIASES_CONFIGPARAM + "[" + i + "] = " + Context . toString ( entry ) ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } } else { throw new IllegalArgumentException ( "Unrecognized type for " + ALIASES_CONFIGPARAM + " - " + aliasList . getClass ( ) . toString ( ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } } } return aliases ; }
Initializes and returns the list of aliases defined in the server - side config JavaScript