本文整理汇总了Java中org.csource.common.NameValuePair类的典型用法代码示例。如果您正苦于以下问题:Java NameValuePair类的具体用法?Java NameValuePair怎么用?Java NameValuePair使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NameValuePair类属于org.csource.common包,在下文中一共展示了NameValuePair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pack_metadata
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* pack metadata array to string
* @param meta_list metadata array
* @return packed metadata
*/
public static String pack_metadata(NameValuePair[] meta_list)
{
if (meta_list.length == 0)
{
return "";
}
StringBuffer sb = new StringBuffer(32 * meta_list.length);
sb.append(meta_list[0].getName()).append(FDFS_FIELD_SEPERATOR).append(meta_list[0].getValue());
for (int i=1; i<meta_list.length; i++)
{
sb.append(FDFS_RECORD_SEPERATOR);
sb.append(meta_list[i].getName()).append(FDFS_FIELD_SEPERATOR).append(meta_list[i].getValue());
}
return sb.toString();
}
示例2: upload_file
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* upload file to storage server (by file name)
* @param cmd the command
* @param group_name the group name to upload file to, can be empty
* @param local_filename local filename to upload
* @param file_ext_name file ext name, do not include dot(.), null to extract ext name from the local filename
* @param meta_list meta info array
* @return 2 elements string array if success:<br>
* <ul><li>results[0]: the group name to store the file </li></ul>
* <ul><li>results[1]: the new created filename</li></ul>
* return null if fail
* @throws IOException if an error occurred
* @throws MyException if an error occurred
*/
protected String[] upload_file(byte cmd, String group_name, String local_filename, String file_ext_name,
NameValuePair[] meta_list) throws IOException, MyException {
File f = new File(local_filename);
FileInputStream fis = new FileInputStream(f);
if (file_ext_name == null) {
int nPos = local_filename.lastIndexOf('.');
if (nPos > 0 && local_filename.length() - nPos <= ProtoCommon.FDFS_FILE_EXT_NAME_MAX_LEN + 1) {
file_ext_name = local_filename.substring(nPos + 1);
}
}
try {
return this.do_upload_file(cmd, group_name, null, null, file_ext_name, f.length(),
new UploadStream(fis, f.length()), meta_list);
} finally {
fis.close();
}
}
示例3: upload_file
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* upload file to storage server (by file name)
* @param cmd the command
* @param group_name the group name to upload file to, can be empty
* @param local_filename local filename to upload
* @param file_ext_name file ext name, do not include dot(.), null to extract ext name from the local filename
* @param meta_list meta info array
* @return 2 elements string array if success:<br>
* <ul><li>results[0]: the group name to store the file </li></ul>
* <ul><li>results[1]: the new created filename</li></ul>
* return null if fail
*/
protected String[] upload_file(byte cmd, String group_name, String local_filename, String file_ext_name,
NameValuePair[] meta_list) throws IOException, MyException
{
File f = new File(local_filename);
FileInputStream fis = new FileInputStream(f);
if (file_ext_name == null)
{
int nPos = local_filename.lastIndexOf('.');
if (nPos > 0 && local_filename.length() - nPos <= ProtoCommon.FDFS_FILE_EXT_NAME_MAX_LEN + 1)
{
file_ext_name = local_filename.substring(nPos+1);
}
}
try
{
return this.do_upload_file(cmd, group_name, null, null, file_ext_name,
f.length(), new UploadStream(fis, f.length()), meta_list);
}
finally
{
fis.close();
}
}
示例4: upload_file1
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* upload file to storage server (by file buff, slave file mode)
* @param master_file_id the master file id to generate the slave file
* @param prefix_name the prefix name to generate the slave file
* @param file_buff file content/buff
* @param file_ext_name file ext name, do not include dot(.)
* @param meta_list meta info array
* @return file id(including group name and filename) if success, <br>
* return null if fail
*/
public String upload_file1(String master_file_id, String prefix_name,
byte[] file_buff, int offset, int length, String file_ext_name,
NameValuePair[] meta_list) throws IOException, MyException
{
String[] parts = new String[2];
this.errno = this.split_file_id(master_file_id, parts);
if (this.errno != 0)
{
return null;
}
parts = this.upload_file(parts[0], parts[1], prefix_name, file_buff,
offset, length, file_ext_name, meta_list);
if (parts != null)
{
return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
}
else
{
return null;
}
}
示例5: upload_file1
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* upload file to storage server (by file name, slave file mode)
* @param master_file_id the master file id to generate the slave file
* @param prefix_name the prefix name to generate the slave file
* @param local_filename local filename to upload
* @param file_ext_name file ext name, do not include dot(.), null to extract ext name from the local filename
* @param meta_list meta info array
* @return file id(including group name and filename) if success, <br>
* return null if fail
*/
public String upload_file1(String master_file_id, String prefix_name,
String local_filename, String file_ext_name, NameValuePair[] meta_list) throws IOException, MyException
{
String[] parts = new String[2];
this.errno = this.split_file_id(master_file_id, parts);
if (this.errno != 0)
{
return null;
}
parts = this.upload_file(parts[0], parts[1], prefix_name,
local_filename, file_ext_name, meta_list);
if (parts != null)
{
return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
}
else
{
return null;
}
}
示例6: upload_file1
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* upload file to storage server (by file buff, slave file mode)
* @param master_file_id the master file id to generate the slave file
* @param prefix_name the prefix name to generate the slave file
* @param file_buff file content/buff
* @param file_ext_name file ext name, do not include dot(.)
* @param meta_list meta info array
* @return file id(including group name and filename) if success, <br>
* return null if fail
* @throws IOException if an error occurred
* @throws MyException if an error occurred
*/
public String upload_file1(String master_file_id, String prefix_name, byte[] file_buff, int offset, int length,
String file_ext_name, NameValuePair[] meta_list) throws IOException, MyException {
String[] parts = new String[2];
this.errno = this.split_file_id(master_file_id, parts);
if (this.errno != 0) {
return null;
}
parts = this.upload_file(parts[0], parts[1], prefix_name, file_buff, offset, length, file_ext_name, meta_list);
if (parts != null) {
return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
} else {
return null;
}
}
示例7: upload_file1
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* upload file to storage server (by file buff, slave file mode)
* @param master_file_id the master file id to generate the slave file
* @param prefix_name the prefix name to generate the slave file
* @param file_buff file content/buff
* @param file_ext_name file ext name, do not include dot(.)
* @param meta_list meta info array
* @return file id(including group name and filename) if success, <br>
* return null if fail
*/
public String upload_file1(String master_file_id, String prefix_name,
byte[] file_buff, String file_ext_name, NameValuePair[] meta_list) throws IOException, MyException
{
String[] parts = new String[2];
this.errno = this.split_file_id(master_file_id, parts);
if (this.errno != 0)
{
return null;
}
parts = this.upload_file(parts[0], parts[1], prefix_name, file_buff, file_ext_name, meta_list);
if (parts != null)
{
return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
}
else
{
return null;
}
}
示例8: upload_file
import org.csource.common.NameValuePair; //导入依赖的package包/类
public String[] upload_file(String local_filename,
NameValuePair[] meta_list) throws IOException, MyException {
int pos = local_filename.lastIndexOf(".");
String file_ext_name = local_filename.substring(pos + 1);
StorageClient storageClient = new StorageClient(trackerServer, storageServer);
return storageClient.upload_file(local_filename, file_ext_name, meta_list);
}
示例9: upload_file
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* upload file to storage server (by file buff, slave file mode)
* @param group_name the group name of master file
* @param master_filename the master file name to generate the slave file
* @param prefix_name the prefix name to generate the slave file
* @param file_buff file content/buff
* @param file_ext_name file ext name, do not include dot(.)
* @param meta_list meta info array
* @return 2 elements string array if success:<br>
* <ul><li>results[0]: the group name to store the file</li></ul>
* <ul><li>results[1]: the new created filename</li></ul>
* return null if fail
*/
public String[] upload_file(String group_name, String master_filename, String prefix_name,
byte[] file_buff, String file_ext_name, NameValuePair[] meta_list) throws IOException, MyException
{
if ((group_name == null || group_name.length() == 0) ||
(master_filename == null || master_filename.length() == 0) ||
(prefix_name == null))
{
throw new MyException("invalid arguement");
}
return this.do_upload_file(ProtoCommon.STORAGE_PROTO_CMD_UPLOAD_SLAVE_FILE, group_name, master_filename, prefix_name,
file_ext_name, file_buff.length, new UploadBuff(file_buff, 0, file_buff.length), meta_list);
}
示例10: upload_appender_file1
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* upload appender file to storage server (by file name)
* @param local_filename local filename to upload
* @param file_ext_name file ext name, do not include dot(.), null to extract ext name from the local filename
* @param meta_list meta info array
* @return file id(including group name and filename) if success, <br>
* return null if fail
*/
public String upload_appender_file1(String local_filename, String file_ext_name,
NameValuePair[] meta_list) throws IOException, MyException
{
String parts[] = this.upload_appender_file(local_filename, file_ext_name, meta_list);
if (parts != null)
{
return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
}
else
{
return null;
}
}
示例11: set_metadata1
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* set metadata items to storage server
* @param file_id the file id(including group name and filename)
* @param meta_list meta item array
* @param op_flag flag, can be one of following values: <br>
* <ul><li> ProtoCommon.STORAGE_SET_METADATA_FLAG_OVERWRITE: overwrite all old
* metadata items</li></ul>
* <ul><li> ProtoCommon.STORAGE_SET_METADATA_FLAG_MERGE: merge, insert when
* the metadata item not exist, otherwise update it</li></ul>
* @return 0 for success, !=0 fail (error code)
*/
public int set_metadata1(String file_id, NameValuePair[] meta_list, byte op_flag) throws IOException, MyException
{
String[] parts = new String[2];
this.errno = this.split_file_id(file_id, parts);
if (this.errno != 0)
{
return this.errno;
}
return this.set_metadata(parts[0], parts[1], meta_list, op_flag);
}
示例12: upload_appender_file1
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* upload appender file to storage server (by callback)
* @param group_name the group name to upload file to, can be empty
* @param file_size the file size
* @param callback the write data callback object
* @param file_ext_name file ext name, do not include dot(.)
* @param meta_list meta info array
* @return file id(including group name and filename) if success, <br>
* return null if fail
*/
public String upload_appender_file1(String group_name, long file_size,
UploadCallback callback, String file_ext_name,
NameValuePair[] meta_list) throws IOException, MyException
{
String parts[] = this.upload_appender_file(group_name, file_size, callback, file_ext_name, meta_list);
if (parts != null)
{
return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
}
else
{
return null;
}
}
示例13: pack_metadata
import org.csource.common.NameValuePair; //导入依赖的package包/类
/**
* pack metadata array to string
* @param meta_list metadata array
* @return packed metadata
*/
public static String pack_metadata(NameValuePair[] meta_list) {
if (meta_list.length == 0) {
return "";
}
StringBuffer sb = new StringBuffer(32 * meta_list.length);
sb.append(meta_list[0].getName()).append(FDFS_FIELD_SEPERATOR).append(meta_list[0].getValue());
for (int i = 1; i < meta_list.length; i++) {
sb.append(FDFS_RECORD_SEPERATOR);
sb.append(meta_list[i].getName()).append(FDFS_FIELD_SEPERATOR).append(meta_list[i].getValue());
}
return sb.toString();
}
示例14: upload_file_bytes
import org.csource.common.NameValuePair; //导入依赖的package包/类
public String upload_file_bytes(byte[] data, String extension, NameValuePair[] meta_list) throws MyException, IOException {
String uploadedFileId = null;
try {
PooledFastResource resource = genericObjectPool.borrowObject();
if (resource != null) {
uploadedFileId = resource.getStorageClient1().upload_file1(data, extension, meta_list);
genericObjectPool.returnObject(resource);
}
} catch (Exception e) {
log.error("上传字节到FastDFS发生异常,文件路径:", e);
}
return uploadedFileId;
}
示例15: upload_file1
import org.csource.common.NameValuePair; //导入依赖的package包/类
public String upload_file1(String filePath, String extension, NameValuePair[] meta_list) throws IOException {
String uploadedFileId = null;
try {
PooledFastResource resource = genericObjectPool.borrowObject();
if (resource != null) {
uploadedFileId = resource.getStorageClient1().upload_file1(filePath, extension, meta_list);
genericObjectPool.returnObject(resource);
}
} catch (Exception e) {
log.error("上传文件到FastDFS发生异常,文件路径:" + filePath, e);
}
return uploadedFileId;
}