mbeandescriptorutil.java

来自「jmx在spring中的实现」· Java 代码 · 共 69 行

JAVA
69
字号
/*
======================================================================

  MBeanDescriptorUtil.java

  Created by Claude Duguay
  Copyright (c) 2005

======================================================================
*/

package com.claudeduguay.mbeans.model;

import java.io.*;

import org.jdom.*;

import com.claudeduguay.util.jdom.*;

public class MBeanDescriptorUtil
{
	protected static DocumentStorage storage = new DocumentStorage();
	
	public static String[] parseCommaSeparatedList(String text)
	{
		if (text == null)
		{
			return new String[0];
		}
		String[] list = text.split(",");
		for (int i = 0; i < list.length; i++)
		{
			list[i] = list[i].trim();
		}
		return text.split(",");
	}
	
	public static String buildCommaSeparatedList(String[] list)
	{
		StringBuffer buffer = new StringBuffer();
		for (int i = 0; i < list.length; i++)
		{
			if (i > 0) buffer.append(", ");
			buffer.append(list[i]);
		}
		return buffer.toString();
	}
	
	public static MBeanDescriptor read(File file)
		throws Exception
	{
		return read(new FileInputStream(file));
	}

	public static MBeanDescriptor read(InputStream input)
		throws Exception
	{
		Document doc = storage.read(input);
		return new MBeanDescriptor(doc);
	}
	
	public static void write(MBeanDescriptor descriptor, OutputStream output) throws IOException, JDOMException
	{
		Document doc = descriptor.buildDocument();
		storage.write(doc, output);
		output.flush();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?