1 package com.android.server.wifi.hotspot2.omadm; 2 3 import java.util.Arrays; 4 import java.util.Collection; 5 import java.util.Map; 6 7 public class RequestDetail { 8 private final String mSppversion; 9 private final String mRedirectURI; 10 private final String mRequestReason; 11 private final String mSessionID; 12 private final String[] mSupportedVersions; 13 private final String[] mSupportedMOs; 14 private final Collection<MOTree> m_MOs; 15 16 public enum RequestFields { 17 SPPVersion, 18 RedirectURI, 19 RequestReason, 20 SessionID, 21 SupportedVersions, 22 SupportedMOs 23 } 24 25 public RequestDetail(Map<RequestFields, String> values, Collection<MOTree> mos) { 26 mSppversion = values.get(RequestFields.SPPVersion); 27 mRedirectURI = values.get(RequestFields.RedirectURI); 28 mRequestReason = values.get(RequestFields.RequestReason); 29 mSessionID = values.get(RequestFields.SessionID); 30 mSupportedVersions = split(values.get(RequestFields.SupportedVersions)); 31 mSupportedMOs = split(values.get(RequestFields.SupportedMOs)); 32 m_MOs = mos; 33 } 34 35 public Collection<MOTree> getMOs() { 36 return m_MOs; 37 } 38 39 private static String[] split(String list) { 40 return list != null ? list.split("[ \n\r]+") : null; 41 } 42 43 @Override 44 public String toString() { 45 StringBuilder sb = new StringBuilder(); 46 47 sb.append("SPPVersion").append(" = '").append(mSppversion).append("'\n"); 48 sb.append("RedirectURI").append(" = '").append(mRedirectURI).append("'\n"); 49 sb.append("RequestReason").append(" = '").append(mRequestReason).append("'\n"); 50 sb.append("SessionID").append(" = '").append(mSessionID).append("'\n"); 51 sb.append("SupportedVersions").append(" = ").append(Arrays.toString(mSupportedVersions)) 52 .append('\n'); 53 sb.append("SupportedMOs").append(" = ").append(Arrays.toString(mSupportedMOs)).append('\n'); 54 sb.append("MOs:\n"); 55 for (MOTree mo : m_MOs) 56 sb.append(mo); 57 58 return sb.toString(); 59 } 60 } 61