本文整理汇总了Java中javax.print.attribute.AttributeSet.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeSet.toArray方法的具体用法?Java AttributeSet.toArray怎么用?Java AttributeSet.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.print.attribute.AttributeSet
的用法示例。
在下文中一共展示了AttributeSet.toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkPrintService
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
* Checks the given print service - own method so it can be used also
* to check application registered print services from PrintServiceLookup.
*
* @param flavor the document flavor which has to be supported.
* @param attributes the attributes which have to be supported.
* @param service the service to check
*
* @return <code>true</code> if all constraints match, <code>false</code>
* otherwise.
*/
public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes,
PrintService service)
{
boolean allAttributesSupported = true;
if (flavor == null || service.isDocFlavorSupported(flavor))
{
if (attributes == null || attributes.size() == 0)
return allAttributesSupported;
Attribute[] atts = attributes.toArray();
for (int i = 0; i < atts.length; i++)
{
if (! service.isAttributeCategorySupported(atts[i].getCategory()))
{
allAttributesSupported = false;
break;
}
}
return allAttributesSupported;
}
return false;
}
示例2: checkPrintService
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
* Checks the given print service - own method so it can be used also
* to check application registered print services from PrintServiceLookup.
*
* @param flavor the document flavor which has to be supported.
* @param attributes the attributes which have to be supported.
* @param service the service to check
*
* @return <code>true</code> if all constraints match, <code>false</code>
* otherwise.
*/
public boolean checkPrintService(DocFlavor flavor, AttributeSet attributes,
PrintService service)
{
boolean allAttributesSupported = true;
if (flavor == null || service.isDocFlavorSupported(flavor))
{
if (attributes == null || attributes.size() == 0)
return allAttributesSupported;
Attribute[] atts = attributes.toArray();
for (int i = 0; i < atts.length; i++)
{
if (! service.isAttributeCategorySupported(atts[i].getCategory()))
{
allAttributesSupported = false;
break;
}
}
return allAttributesSupported;
}
return false;
}
示例3: getUnsupportedAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
public AttributeSet getUnsupportedAttributes(final DocFlavor flavor,
final AttributeSet attributes) {
checkFlavor(flavor);
if (attributes == null) {
return null;
}
final AttributeSet result = new HashAttributeSet();
for (Attribute attr : attributes.toArray()) {
if (!isAttributeValueSupported(attr, flavor, attributes)) {
result.add(attr);
}
}
return result.size() > 0 ? result : null;
}
示例4: getUnsupportedAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
AttributeSet attributes) {
if (attributes == null) {
return null;
}
if (flavor != null && !isDocFlavorSupported(flavor)) {
throw new IllegalArgumentException("Flavor " + flavor.getMimeType()
+ " is not supported by print service");
}
Attribute[] attrs = attributes.toArray();
HashAttributeSet unsupported = new HashAttributeSet();
for (int i = 0; i < attrs.length; i++) {
if (!isAttributeValueSupported(attrs[i], flavor, attributes)) {
unsupported.add(attrs[i]);
}
}
if (unsupported.size() > 0) {
return unsupported;
}
return null;
}
示例5: getUnsupportedAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
AttributeSet attributes) {
if (flavor != null && !isDocFlavorSupported(flavor)) {
throw new IllegalArgumentException("flavor " + flavor +
"is not supported");
}
if (attributes == null) {
return null;
}
Attribute attr;
AttributeSet unsupp = new HashAttributeSet();
Attribute[] attrs = attributes.toArray();
for (int i=0; i<attrs.length; i++) {
try {
attr = attrs[i];
if (!isAttributeCategorySupported(attr.getCategory())) {
unsupp.add(attr);
} else if (!isAttributeValueSupported(attr, flavor,
attributes)) {
unsupp.add(attr);
}
} catch (ClassCastException e) {
}
}
if (unsupp.isEmpty()) {
return null;
} else {
return unsupp;
}
}
示例6: removeUnsupportedAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
* Removes any attributes from the given AttributeSet that are
* unsupported by the given PrintService/DocFlavor combination.
*/
private static void removeUnsupportedAttributes(PrintService ps,
DocFlavor flavor,
AttributeSet aset)
{
AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
aset);
if (asUnsupported != null) {
Attribute[] usAttrs = asUnsupported.toArray();
for (int i=0; i<usAttrs.length; i++) {
Class category = usAttrs[i].getCategory();
if (ps.isAttributeCategorySupported(category)) {
Attribute attr =
(Attribute)ps.getDefaultAttributeValue(category);
if (attr != null) {
aset.add(attr);
} else {
aset.remove(category);
}
} else {
aset.remove(category);
}
}
}
}
示例7: getUnsupportedAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
AttributeSet attributes) {
if (flavor != null && !isDocFlavorSupported(flavor)) {
throw new IllegalArgumentException("flavor " + flavor +
"is not supported");
}
if (attributes == null) {
return null;
}
Attribute attr;
AttributeSet unsupp = new HashAttributeSet();
Attribute []attrs = attributes.toArray();
for (int i=0; i<attrs.length; i++) {
try {
attr = attrs[i];
if (!isAttributeCategorySupported(attr.getCategory())) {
unsupp.add(attr);
}
else if (!isAttributeValueSupported(attr, flavor, attributes)) {
unsupp.add(attr);
}
} catch (ClassCastException e) {
}
}
if (unsupp.isEmpty()) {
return null;
} else {
return unsupp;
}
}
示例8: getUnsupportedAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
AttributeSet attributes) {
if (flavor != null && !isDocFlavorSupported(flavor)) {
throw new IllegalArgumentException("flavor " + flavor +
"is not supported");
}
if (attributes == null) {
return null;
}
Attribute attr;
AttributeSet unsupp = new HashAttributeSet();
Attribute []attrs = attributes.toArray();
for (int i=0; i<attrs.length; i++) {
try {
attr = attrs[i];
if (!isAttributeCategorySupported(attr.getCategory())) {
unsupp.add(attr);
} else if (!isAttributeValueSupported(attr, flavor,
attributes)) {
unsupp.add(attr);
}
} catch (ClassCastException e) {
}
}
if (unsupp.isEmpty()) {
return null;
} else {
return unsupp;
}
}
示例9: removeUnsupportedAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
* Removes any attributes from the given {@code AttributeSet} that are
* unsupported by the given {@code PrintService/DocFlavor} combination.
*/
private static void removeUnsupportedAttributes(PrintService ps,
DocFlavor flavor,
AttributeSet aset)
{
AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
aset);
if (asUnsupported != null) {
Attribute[] usAttrs = asUnsupported.toArray();
for (int i=0; i<usAttrs.length; i++) {
Class<? extends Attribute> category = usAttrs[i].getCategory();
if (ps.isAttributeCategorySupported(category)) {
Attribute attr =
(Attribute)ps.getDefaultAttributeValue(category);
if (attr != null) {
aset.add(attr);
} else {
aset.remove(category);
}
} else {
aset.remove(category);
}
}
}
}
示例10: getUnsupportedAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
AttributeSet attributes) {
if (flavor != null && !isDocFlavorSupported(flavor)) {
throw new IllegalArgumentException("flavor " + flavor +
" is not supported");
}
if (attributes == null) {
return null;
}
Attribute attr;
AttributeSet unsupp = new HashAttributeSet();
Attribute []attrs = attributes.toArray();
for (int i=0; i<attrs.length; i++) {
try {
attr = attrs[i];
if (!isAttributeCategorySupported(attr.getCategory())) {
unsupp.add(attr);
}
else if (!isAttributeValueSupported(attr, flavor, attributes)) {
unsupp.add(attr);
}
} catch (ClassCastException e) {
}
}
if (unsupp.isEmpty()) {
return null;
} else {
return unsupp;
}
}
示例11: removeUnsupportedAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
* Removes any attributes from the given AttributeSet that are
* unsupported by the given PrintService/DocFlavor combination.
*/
private static void removeUnsupportedAttributes(PrintService ps,
DocFlavor flavor,
AttributeSet aset)
{
AttributeSet asUnsupported = ps.getUnsupportedAttributes(flavor,
aset);
if (asUnsupported != null) {
Attribute[] usAttrs = asUnsupported.toArray();
for (int i=0; i<usAttrs.length; i++) {
Class<? extends Attribute> category = usAttrs[i].getCategory();
if (ps.isAttributeCategorySupported(category)) {
Attribute attr =
(Attribute)ps.getDefaultAttributeValue(category);
if (attr != null) {
aset.add(attr);
} else {
aset.remove(category);
}
} else {
aset.remove(category);
}
}
}
}
示例12: writeAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
* Writes the given attribute groups of the given map instance
* (key=group, values=set of attributes) into the supplied data
* output stream.
*
* @param attributes the set with the attributes.
*
* @throws IOException if thrown by the used DataOutputStream.
* @throws IppException if unknown attributes occur.
*/
public void writeAttributes(AttributeSet attributes)
throws IOException, IppException
{
Attribute[] attributeArray = attributes.toArray();
for (int i = 0; i < attributeArray.length; i++)
{
logger.log(Component.IPP, "Attribute: Name: <" + attributeArray[i]
.getCategory().getName() + "> Value: <"
+ attributeArray[i].toString() + ">");
if (attributeArray[i] instanceof IntegerSyntax)
write((IntegerSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof TextSyntax)
write((TextSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof DateTimeSyntax)
write((DateTimeSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof ResolutionSyntax)
write((ResolutionSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof SetOfIntegerSyntax)
write((SetOfIntegerSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof EnumSyntax)
write((EnumSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof URISyntax)
write((URISyntax) attributeArray[i]);
else if (attributeArray[i] instanceof CharsetSyntax)
write((CharsetSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof NaturalLanguageSyntax)
write((NaturalLanguageSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof RequestedAttributes)
write((RequestedAttributes) attributeArray[i]);
else
throw new IppException("Unknown syntax type");
}
}
示例13: writeAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
/**
* Writes the given attribute groups of the given map instance
* (key=group, values=set of attributes) into the supplied data
* output stream.
*
* @param attributes the set with the attributes.
*
* @throws IOException if thrown by the used DataOutputStream.
* @throws IppException if unknown attributes occur.
*/
public void writeAttributes(AttributeSet attributes)
throws IOException, IppException
{
Attribute[] attributeArray = attributes.toArray();
for (int i = 0; i < attributeArray.length; i++)
{
logger.log(Component.IPP, "Attribute: Name: <" + attributeArray[i]
.getCategory().getName() + "> Value: <"
+ attributeArray[i].toString() + ">");
if (attributeArray[i] instanceof IntegerSyntax)
write((IntegerSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof TextSyntax)
write((TextSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof DateTimeSyntax)
write((DateTimeSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof ResolutionSyntax)
write((ResolutionSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof SetOfIntegerSyntax)
write((SetOfIntegerSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof EnumSyntax)
write((EnumSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof URISyntax)
write((URISyntax) attributeArray[i]);
else if (attributeArray[i] instanceof CharsetSyntax)
write((CharsetSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof NaturalLanguageSyntax)
write((NaturalLanguageSyntax) attributeArray[i]);
else if (attributeArray[i] instanceof RequestedAttributes)
write((RequestedAttributes) attributeArray[i]);
else
throw new IppException("Unknown syntax type");
}
}
示例14: setAttributes
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
public void setAttributes(final AttributeSet attrs) {
if (attrs != null) {
for (Attribute attr : attrs.toArray()) {
setAttribute(attr);
}
}
}
示例15: getAttribute
import javax.print.attribute.AttributeSet; //导入方法依赖的package包/类
private <T extends Attribute> T getAttribute(final Class<T> c,
final AttributeSet... attrSets) {
for (AttributeSet attrs : attrSets) {
if (attrs != null) {
for (Attribute attr : attrs.toArray()) {
if (c.equals(attr.getCategory())) {
return c.cast(attr);
}
}
}
}
return null;
}