com.aspose.words
Class WarningInfoCollection

java.lang.Object
    extended by com.aspose.words.WarningInfoCollection
All Implemented Interfaces:
IWarningCallback, java.lang.Iterable

public class WarningInfoCollection 
extends java.lang.Object

Represents a typed collection of WarningInfo objects.

You can use this collection object as the simplest form of IWarningCallback implementation to gather all warnings that Aspose.Words generates during a load or save operation. Create an instance of this class and assign it to the LoadOptions.WarningCallback or DocumentBase.WarningCallback property.

Example:

Shows how to implement the IWarningCallback to be notified of any font substitution during document save.
public static class HandleDocumentWarnings implements IWarningCallback {
    /**
     * Our callback only needs to implement the "Warning" method. This method is called whenever there is a
     * potential issue during document processing. The callback can be set to listen for warnings generated during document
     * load and/or document save.
     */
    public void warning(final WarningInfo info) {
        // We are only interested in fonts being substituted.
        if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
            System.out.println("Font substitution: " + info.getDescription());
        }
    }

}
See Also:
WarningInfo, IWarningCallback

Constructor Summary
WarningInfoCollection()
          
 
Property Getters/Setters Summary
intgetCount()
           Gets the number of elements contained in the collection.
WarningInfoget(int index)
           Gets an item at the specified index.
 
Method Summary
voidclear()
           Removes all elements from the collection.
java.util.Iterator<WarningInfo>iterator()
           Returns an iterator object that can be used to iterate over all items in the collection.
voidwarning(WarningInfo info)
           Implements the IWarningCallback interface. Adds a warning to this collection.
 

Constructor Detail

WarningInfoCollection

public WarningInfoCollection()

Property Getters/Setters Detail

getCount

public int getCount()
Gets the number of elements contained in the collection.

get

public WarningInfo get(int index)
Gets an item at the specified index.
Parameters:
index - Zero-based index of the item.

Method Detail

clear

public void clear()
Removes all elements from the collection.

Example:

Shows how to read and clear a collection of warnings.
WarningInfoCollection wic = new WarningInfoCollection();

Iterator enumerator = wic.iterator();
while (enumerator.hasNext()) {
    WarningInfo wi = (WarningInfo) enumerator.next();
    System.out.println(wi.getDescription());
}

wic.clear();

iterator

public java.util.Iterator<WarningInfoiterator()
Returns an iterator object that can be used to iterate over all items in the collection.

Example:

Shows how to read and clear a collection of warnings.
WarningInfoCollection wic = new WarningInfoCollection();

Iterator enumerator = wic.iterator();
while (enumerator.hasNext()) {
    WarningInfo wi = (WarningInfo) enumerator.next();
    System.out.println(wi.getDescription());
}

wic.clear();

warning

public void warning(WarningInfo info)
Implements the IWarningCallback interface. Adds a warning to this collection.

Example:

Shows how to implement the IWarningCallback to be notified of any font substitution during document save.
public static class HandleDocumentWarnings implements IWarningCallback {
    /**
     * Our callback only needs to implement the "Warning" method. This method is called whenever there is a
     * potential issue during document processing. The callback can be set to listen for warnings generated during document
     * load and/or document save.
     */
    public void warning(final WarningInfo info) {
        // We are only interested in fonts being substituted.
        if (info.getWarningType() == WarningType.FONT_SUBSTITUTION) {
            System.out.println("Font substitution: " + info.getDescription());
        }
    }

}

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.