public static ConditionTerm create ( StreamTokenizer tokenizer ) throws WebDAVException { ConditionTerm term = new ConditionTerm ( ) ; try { int token = tokenizer . ttype ; if ( token == ' ' ) token = tokenizer . nextToken ( ) ; else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , "(" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ while ( token == StreamTokenizer . TT_WORD || token == ' ' || token == ' ' ) { term . addConditionFactor ( ConditionFactor . create ( tokenizer ) ) ; token = tokenizer . ttype ; } if ( token == ' ' ) token = tokenizer . nextToken ( ) ; else throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissing" , String . valueOf ( token ) , ")" ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ } catch ( IOException exc ) { // ignore or log? } if ( ! term . getConditionFactors ( ) . hasMoreElements ( ) ) throw new WebDAVException ( IResponse . SC_BAD_REQUEST , Policy . bind ( "error.parseMissingStateOrEntity" ) ) ; //$NON-NLS-1$ return term ; }
Create a ConditionTerm by parsing the given If header as defined by section 9 . 4 in the WebDAV spec .