private Pair<HashStepType,HashChainType> fetchHashStep(String uri,HashChainType currentChain) throws Exception {
  int hashIndex=uri.indexOf('#');
  if (hashIndex < 0) {
    throw new CodedException(X_MALFORMED_HASH_CHAIN,"Invalid hash step URI: %s",uri);
  }
  String baseUri=uri.substring(0,hashIndex);
  String fragment=uri.substring(hashIndex + 1);
  if (fragment.isEmpty()) {
    throw new CodedException(X_MALFORMED_HASH_CHAIN,"Invalid hash step URI: %s",uri);
  }
  HashChainType hashChain;
  if (baseUri.isEmpty()) {
    hashChain=currentChain;
  }
 else {
    hashChain=getHashChain(baseUri);
  }
  for (  HashStepType step : hashChain.getHashStep()) {
    if (fragment.equals(step.getId())) {
      return new ImmutablePair<>(step,hashChain);
    }
  }
  throw new CodedException(X_MALFORMED_HASH_CHAIN,"Invalid hash step URI: %s",uri);
}

private Pair < HashStepType , HashChainType > fetchHashStep ( String uri , HashChainType currentChain ) throws Exception { int hashIndex = uri . indexOf ( '#' ) ; if ( hashIndex < 0 ) { throw new CodedException ( X_MALFORMED_HASH_CHAIN , "Invalid hash step URI: %s" , uri ) ; } String baseUri = uri . substring ( 0 , hashIndex ) ; String fragment = uri . substring ( hashIndex + 1 ) ; if ( fragment . isEmpty ( ) ) { throw new CodedException ( X_MALFORMED_HASH_CHAIN , "Invalid hash step URI: %s" , uri ) ; } HashChainType hashChain ; if ( baseUri . isEmpty ( ) ) { hashChain = currentChain ; } else { hashChain = getHashChain ( baseUri ) ; } for ( HashStepType step : hashChain . getHashStep ( ) ) { if ( fragment . equals ( step . getId ( ) ) ) { return new ImmutablePair < > ( step , hashChain ) ; } } throw new CodedException ( X_MALFORMED_HASH_CHAIN , "Invalid hash step URI: %s" , uri ) ; }
retrieve hash step based on the uri .
