本文整理汇总了Java中org.apache.avalon.framework.configuration.Configuration.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.getAttribute方法的具体用法?Java Configuration.getAttribute怎么用?Java Configuration.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.avalon.framework.configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.getAttribute方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getQualfierFromConfiguration
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
private static FontQualifier getQualfierFromConfiguration(Configuration cfg)
throws FOPException {
String fontFamily = cfg.getAttribute("font-family", null);
if (fontFamily == null) {
throw new FOPException("substitution qualifier must have a font-family");
}
FontQualifier qualifier = new FontQualifier();
qualifier.setFontFamily(fontFamily);
String fontWeight = cfg.getAttribute("font-weight", null);
if (fontWeight != null) {
qualifier.setFontWeight(fontWeight);
}
String fontStyle = cfg.getAttribute("font-style", null);
if (fontStyle != null) {
qualifier.setFontStyle(fontStyle);
}
return qualifier;
}
示例2: TaskDef
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
public TaskDef(Configuration cfg) throws ConfigurationException {
this.fo = cfg.getAttribute("fo", null);
if (this.fo == null) {
this.xml = cfg.getAttribute("xml");
this.xslt = cfg.getAttribute("xslt", null);
if (this.xslt != null) {
TransformerFactory factory = TransformerFactory.newInstance();
Source xsltSource = new StreamSource(new File(xslt));
try {
this.templates = factory.newTemplates(xsltSource);
} catch (TransformerConfigurationException tce) {
throw new ConfigurationException("Invalid XSLT", tce);
}
}
}
}
示例3: getFontTriplet
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
/**
* Creates a new FontTriplet given a triple Configuration
*
* @param tripletCfg a triplet configuration
* @return a font triplet font key
* @throws FOPException thrown if a FOP exception occurs
*/
private FontTriplet getFontTriplet(Configuration tripletCfg) throws FOPException {
try {
String name = tripletCfg.getAttribute("name");
if (name == null) {
LogUtil.handleError(log, "font-triplet without name", strict);
return null;
}
String weightStr = tripletCfg.getAttribute("weight");
if (weightStr == null) {
LogUtil.handleError(log, "font-triplet without weight", strict);
return null;
}
int weight = FontUtil.parseCSS2FontWeight(FontUtil.stripWhiteSpace(weightStr));
String style = tripletCfg.getAttribute("style");
if (style == null) {
LogUtil.handleError(log, "font-triplet without style", strict);
return null;
} else {
style = FontUtil.stripWhiteSpace(style);
}
return FontInfo.createFontKey(name, style, weight);
} catch (ConfigurationException e) {
LogUtil.handleException(log, e, strict);
}
return null;
}
示例4: getFontTriplet
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
/**
* Creates a new FontTriplet given a triple Configuration
*
* @param tripletCfg a triplet configuration
* @return a font triplet font key
* @throws FOPException thrown if a FOP exception occurs
*/
private FontTriplet getFontTriplet(Configuration tripletCfg) throws FOPException {
try {
String name = tripletCfg.getAttribute("name");
if (name == null) {
LogUtil.handleError(log, "font-triplet without name", strict);
return null;
}
String weightStr = tripletCfg.getAttribute("weight");
if (weightStr == null) {
LogUtil.handleError(log, "font-triplet without weight", strict);
return null;
}
int weight = FontUtil.parseCSS2FontWeight(FontUtil.stripWhiteSpace(weightStr));
String style = tripletCfg.getAttribute("style");
if (style == null) {
LogUtil.handleError(log, "font-triplet without style", strict);
return null;
} else {
style = FontUtil.stripWhiteSpace(style);
}
return FontInfo.createFontKey(name, style, weight);
} catch (ConfigurationException e) {
LogUtil.handleException(log, e, strict);
}
return null;
}
示例5: configureImageLoading
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
private void configureImageLoading(Configuration parent, boolean strict) throws FOPException {
if (parent == null) {
return;
}
ImageImplRegistry registry = factory.getImageManager().getRegistry();
Configuration[] penalties = parent.getChildren("penalty");
try {
for (int i = 0, c = penalties.length; i < c; i++) {
Configuration penaltyCfg = penalties[i];
String className = penaltyCfg.getAttribute("class");
String value = penaltyCfg.getAttribute("value");
Penalty p = null;
if (value.toUpperCase().startsWith("INF")) {
p = Penalty.INFINITE_PENALTY;
} else {
try {
p = Penalty.toPenalty(Integer.parseInt(value));
} catch (NumberFormatException nfe) {
LogUtil.handleException(log, nfe, strict);
}
}
if (p != null) {
registry.setAdditionalPenalty(className, p);
}
}
} catch (ConfigurationException e) {
LogUtil.handleException(log, e, strict);
}
}
示例6: getMessage
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
/**
* Extracts the message from the barcode XML. Escaped Unicode characters are unescaped.
* @param cfg the configuration object containing the barcode XML
* @return the message
* @throws ConfigurationException if an error occurs retrieving values from the configuration
*/
public static String getMessage(Configuration cfg) throws ConfigurationException {
String msg;
try {
msg = cfg.getAttribute("message");
} catch (ConfigurationException ce) {
try {
msg = cfg.getAttribute("msg"); //for compatibility
} catch (ConfigurationException ce1) {
throw ce;
}
}
msg = MessageUtil.unescapeUnicode(msg);
return msg;
}
示例7: createProperty
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
private static JMeterProperty createProperty(Configuration config, String testClass) throws IllegalAccessException,
ClassNotFoundException, InstantiationException {
String value = config.getValue(""); // $NON-NLS-1$
String name = config.getAttribute("name", value); // $NON-NLS-1$
String oname = name;
String type = config.getAttribute("propType", StringProperty.class.getName()); // $NON-NLS-1$
// Do upgrade translation:
name = NameUpdater.getCurrentName(name, testClass);
if (TestElement.GUI_CLASS.equals(name)) {
value = NameUpdater.getCurrentName(value);
} else if (TestElement.TEST_CLASS.equals(name)) {
value=testClass; // must always agree
} else {
value = NameUpdater.getCurrentName(value, name, testClass);
}
// Delete any properties whose name converts to the empty string
if (oname.length() != 0 && name.length()==0) {
return null;
}
// Create the property:
JMeterProperty prop = (JMeterProperty) Class.forName(type).newInstance();
prop.setName(name);
prop.setObjectValue(value);
return prop;
}
示例8: buildFilterMapFromConfiguration
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
/**
* Builds a filter map from an Avalon Configuration object.
*
* @param cfg the Configuration object
* @return Map the newly built filter map
* @throws ConfigurationException if a filter list is defined twice
*/
public static Map buildFilterMapFromConfiguration(Configuration cfg)
throws ConfigurationException {
Map filterMap = new java.util.HashMap();
Configuration[] filterLists = cfg.getChildren("filterList");
for (int i = 0; i < filterLists.length; i++) {
Configuration filters = filterLists[i];
String type = filters.getAttribute("type", null);
Configuration[] filt = filters.getChildren("value");
List filterList = new java.util.ArrayList();
for (int j = 0; j < filt.length; j++) {
String name = filt[j].getValue();
filterList.add(name);
}
if (type == null) {
type = PDFFilterList.DEFAULT_FILTER;
}
if (!filterList.isEmpty() && log.isDebugEnabled()) {
StringBuffer debug = new StringBuffer("Adding PDF filter");
if (filterList.size() != 1) {
debug.append("s");
}
debug.append(" for type ").append(type).append(": ");
for (int j = 0; j < filterList.size(); j++) {
if (j != 0) {
debug.append(", ");
}
debug.append(filterList.get(j));
}
log.debug(debug.toString());
}
if (filterMap.get(type) != null) {
throw new ConfigurationException("A filterList of type '"
+ type + "' has already been defined");
}
filterMap.put(type, filterList);
}
return filterMap;
}
示例9: layout
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
/**
* layout this formatting object.
*
* @param area the area to layout the object into
*
* @return the status of the layout
*/
public int layout(final Area area) throws FOPException {
if (!(area instanceof ForeignObjectArea)) {
// this is an error
throw new FOPException("Barcode not in fo:instream-foreign-object");
}
if (this.marker == START) {
this.fs = area.getFontState();
this.marker = 0;
}
//MessageHandler.logln("Creating barcode area");
/* create a barcode area */
/* if width and height are zero, get the bounds of the content. */
final ForeignObjectArea foa = (ForeignObjectArea)area;
Element e = this.doc.getDocumentElement();
//if(!e.hasAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns")) {
e.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns", BarcodeConstants.NAMESPACE);
//}
Configuration cfg = ConfigurationUtil.buildConfiguration(this.doc);
try {
String msg = ConfigurationUtil.getMessage(cfg);
msg = MessageUtil.unescapeUnicode(msg);
int orientation = cfg.getAttributeAsInteger("orientation", 0);
//MessageHandler.logln("Barcode message: " + msg);
final String renderMode = cfg.getAttribute("render-mode", "native");
//MessageHandler.logln("Render mode: " + renderMode);
BarcodeGenerator bargen = BarcodeUtil.getInstance().
createBarcodeGenerator(cfg);
String expandedMsg = VariableUtil.getExpandedMessage(foa.getPage(), msg);
BarcodeDimension bardim = bargen.calcDimensions(expandedMsg);
final float w = (float)UnitConv.mm2pt(bardim.getWidthPlusQuiet(orientation)) * 1000;
final float h = (float)UnitConv.mm2pt(bardim.getHeightPlusQuiet(orientation)) * 1000;
BarcodeArea barcodeArea = createArea(fs, w, h);
barcodeArea.setParent(foa);
barcodeArea.setPage(foa.getPage());
barcodeArea.setBarcode(bargen, expandedMsg, renderMode, orientation);
barcodeArea.start();
barcodeArea.end();
/* add the SVG area to the containing area */
foa.setObject(barcodeArea);
foa.setIntrinsicWidth(barcodeArea.getWidth());
foa.setIntrinsicHeight(barcodeArea.getHeight());
/* return status */
return Status.OK;
} catch (ConfigurationException ce) {
MessageHandler.errorln("Error in barcode XML: " + ce.getMessage());
throw new FOPException("Error in barcode XML", ce);
} catch (BarcodeException be) {
MessageHandler.errorln("Error generating barcode: " + be.getMessage());
throw new FOPException("Error generating barcode", be);
}
}
示例10: handleXML
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void handleXML(RendererContext context,
Document doc, String ns) throws Exception {
Configuration cfg = ConfigurationUtil.buildConfiguration(doc);
String msg = ConfigurationUtil.getMessage(cfg);
if (DEBUG) {
System.out.println("Barcode message: " + msg);
}
String renderMode = cfg.getAttribute("render-mode", "native");
int orientation = cfg.getAttributeAsInteger("orientation", 0);
orientation = BarcodeDimension.normalizeOrientation(orientation);
PageViewport page = (PageViewport)context.getProperty(PAGE_VIEWPORT);
BarcodeGenerator bargen = BarcodeUtil.getInstance().
createBarcodeGenerator(cfg);
String expandedMsg = VariableUtil.getExpandedMessage(
page, msg);
boolean handled = false;
String effRenderMode = renderMode;
if ("native".equals(renderMode)) {
if (context.getProperty(PS_GENERATOR) != null) {
renderUsingEPS(context, bargen, expandedMsg, orientation);
effRenderMode = "native";
handled = true;
}
} else if ("g2d".equals(renderMode)) {
handled = renderUsingGraphics2D(context, bargen, expandedMsg, orientation);
if (handled) {
effRenderMode = "g2d";
}
} else if ("bitmap".equals(renderMode)) {
handled = renderUsingBitmap(context, bargen, expandedMsg, orientation);
if (handled) {
effRenderMode = "bitmap";
}
}
if (!handled) {
//Convert the Barcode XML to SVG and let it render through
//an SVG handler
convertToSVG(context, bargen, expandedMsg, orientation);
effRenderMode = "svg";
}
if (DEBUG) {
System.out.println("Effective render mode: " + effRenderMode);
}
}
示例11: createTestElement
import org.apache.avalon.framework.configuration.Configuration; //导入方法依赖的package包/类
private static TestElement createTestElement(Configuration config) throws ConfigurationException,
ClassNotFoundException, IllegalAccessException, InstantiationException {
TestElement element = null;
String testClass = config.getAttribute("class"); // $NON-NLS-1$
String gui_class=""; // $NON-NLS-1$
Configuration[] children = config.getChildren();
for (int i = 0; i < children.length; i++) {
if (children[i].getName().equals("property")) { // $NON-NLS-1$
if (children[i].getAttribute("name").equals(TestElement.GUI_CLASS)){ // $NON-NLS-1$
gui_class=children[i].getValue();
}
}
}
String newClass = NameUpdater.getCurrentTestName(testClass,gui_class);
element = (TestElement) Class.forName(newClass).newInstance();
for (int i = 0; i < children.length; i++) {
if (children[i].getName().equals("property")) { // $NON-NLS-1$
try {
JMeterProperty prop = createProperty(children[i], newClass);
if (prop!=null) {
element.setProperty(prop);
}
} catch (Exception ex) {
log.error("Problem loading property", ex);
element.setProperty(children[i].getAttribute("name"), ""); // $NON-NLS-1$ // $NON-NLS-2$
}
} else if (children[i].getName().equals("testelement")) { // $NON-NLS-1$
element.setProperty(new TestElementProperty(children[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$
createTestElement(children[i])));
} else if (children[i].getName().equals("collection")) { // $NON-NLS-1$
element.setProperty(new CollectionProperty(children[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$
createCollection(children[i], newClass)));
} else if (children[i].getName().equals("map")) { // $NON-NLS-1$
element.setProperty(new MapProperty(children[i].getAttribute("name", ""), // $NON-NLS-1$ // $NON-NLS-2$
createMap(children[i],newClass)));
}
}
return element;
}