public static < T extends SharedAccessPolicy > void writeSharedAccessIdentifiersToStream ( final HashMap < String , T > sharedAccessPolicies , final StringWriter outWriter ) throws IllegalArgumentException , IllegalStateException , IOException { Utility . assertNotNull ( "sharedAccessPolicies" , sharedAccessPolicies ) ; Utility . assertNotNull ( "outWriter" , outWriter ) ; final XmlSerializer xmlw = Utility . getXmlSerializer ( outWriter ) ; if ( sharedAccessPolicies . keySet ( ) . size ( ) > Constants . MAX_SHARED_ACCESS_POLICY_IDENTIFIERS ) { final String errorMessage = String . format ( SR . TOO_MANY_SHARED_ACCESS_POLICY_IDENTIFIERS , sharedAccessPolicies . keySet ( ) . size ( ) , Constants . MAX_SHARED_ACCESS_POLICY_IDENTIFIERS ) ; throw new IllegalArgumentException ( errorMessage ) ; } // default is UTF8 xmlw . startDocument ( Constants . UTF8_CHARSET , true ) ; xmlw . startTag ( Constants . EMPTY_STRING , Constants . SIGNED_IDENTIFIERS_ELEMENT ) ; for ( final Entry < String , T > entry : sharedAccessPolicies . entrySet ( ) ) { final SharedAccessPolicy policy = entry . getValue ( ) ; xmlw . startTag ( Constants . EMPTY_STRING , Constants . SIGNED_IDENTIFIER_ELEMENT ) ; // Set the identifier Utility . serializeElement ( xmlw , Constants . ID , entry . getKey ( ) ) ; xmlw . startTag ( Constants . EMPTY_STRING , Constants . ACCESS_POLICY ) ; // Set the Start Time Utility . serializeElement ( xmlw , Constants . START , Utility . getUTCTimeOrEmpty ( policy . getSharedAccessStartTime ( ) ) . toString ( ) ) ; // Set the Expiry Time Utility . serializeElement ( xmlw , Constants . EXPIRY , Utility . getUTCTimeOrEmpty ( policy . getSharedAccessExpiryTime ( ) ) . toString ( ) ) ; // Set the Permissions Utility . serializeElement ( xmlw , Constants . PERMISSION , policy . permissionsToString ( ) ) ; // end AccessPolicy xmlw . endTag ( Constants . EMPTY_STRING , Constants . ACCESS_POLICY ) ; // end SignedIdentifier xmlw . endTag ( Constants . EMPTY_STRING , Constants . SIGNED_IDENTIFIER_ELEMENT ) ; } // end SignedIdentifiers xmlw . endTag ( Constants . EMPTY_STRING , Constants . SIGNED_IDENTIFIERS_ELEMENT ) ; // end doc xmlw . endDocument ( ) ; }
RESERVED FOR INTERNAL USE . Writes a collection of shared access policies to the specified stream in XML format .