예제 #1
0
 /// <exception cref="System.IO.IOException"/>
 private void PrintXAttr(string name, byte[] value)
 {
     if (value != null)
     {
         if (value.Length != 0)
         {
             @out.WriteLine(name + "=" + XAttrCodec.EncodeValue(value, encoding));
         }
         else
         {
             @out.WriteLine(name);
         }
     }
 }
예제 #2
0
        /// <exception cref="System.IO.IOException"/>
        private static IDictionary <string, object> ToJsonMap(XAttr xAttr, XAttrCodec encoding
                                                              )
        {
            if (xAttr == null)
            {
                return(null);
            }
            IDictionary <string, object> m = new SortedDictionary <string, object>();

            m["name"]  = XAttrHelper.GetPrefixName(xAttr);
            m["value"] = xAttr.GetValue() != null?XAttrCodec.EncodeValue(xAttr.GetValue(),
                                                                         encoding) : null;

            return(m);
        }
예제 #3
0
        /// <summary>Converts xAttrs to a JSON object.</summary>
        /// <param name="xAttrs">file xAttrs.</param>
        /// <param name="encoding">format of xattr values.</param>
        /// <returns>The JSON representation of the xAttrs.</returns>
        /// <exception cref="System.IO.IOException"></exception>
        private static IDictionary XAttrsToJSON(IDictionary <string, byte[]> xAttrs, XAttrCodec
                                                encoding)
        {
            IDictionary jsonMap   = new LinkedHashMap();
            JSONArray   jsonArray = new JSONArray();

            if (xAttrs != null)
            {
                foreach (KeyValuePair <string, byte[]> e in xAttrs)
                {
                    IDictionary json = new LinkedHashMap();
                    json[HttpFSFileSystem.XattrNameJson] = e.Key;
                    if (e.Value != null)
                    {
                        json[HttpFSFileSystem.XattrValueJson] = XAttrCodec.EncodeValue(e.Value, encoding);
                    }
                    jsonArray.AddItem(json);
                }
            }
            jsonMap[HttpFSFileSystem.XattrsJson] = jsonArray;
            return(jsonMap);
        }
예제 #4
0
 /// <summary>Params for setting an xAttr</summary>
 /// <exception cref="System.IO.IOException"/>
 public static string SetXAttrParam(string name, byte[] value)
 {
     return("xattr.name=" + name + "&xattr.value=" + XAttrCodec.EncodeValue(value, XAttrCodec
                                                                            .Hex) + "&encoding=hex&flag=create");
 }