com.aspose.words
Class DocumentLoadingArgs

java.lang.Object
    extended by com.aspose.words.DocumentLoadingArgs

public class DocumentLoadingArgs 
extends java.lang.Object

An argument passed into IDocumentLoadingCallback.notify(com.aspose.words.DocumentLoadingArgs).

To learn more, visit the Specify Load Options documentation article.

Example:

Shows how to notify the user if document loading exceeded expected loading time.
public void progressCallback() throws Exception
{
    LoadingProgressCallback progressCallback = new LoadingProgressCallback();

    LoadOptions loadOptions = new LoadOptions(); { loadOptions.setProgressCallback(progressCallback); }

    try
    {
        new Document(getMyDir() + "Big document.docx", loadOptions);
    }
    catch (IllegalStateException exception)
    {
        System.out.println(exception.getMessage());
        // Handle loading duration issue.
    }
}

/// <summary>
/// Cancel a document loading after the "MaxDuration" seconds.
/// </summary>
public static class LoadingProgressCallback implements IDocumentLoadingCallback
{
    /// <summary>
    /// Ctr.
    /// </summary>
    public LoadingProgressCallback()
    {
        mLoadingStartedAt = new Date();
    }

    /// <summary>
    /// Callback method which called during document loading.
    /// </summary>
    /// <param name="args">Loading arguments.</param>
    public void notify(DocumentLoadingArgs args)
    {
        Date canceledAt = new Date();
        long diff = canceledAt.getTime() - mLoadingStartedAt.getTime();
        long ellapsedSeconds = TimeUnit.MILLISECONDS.toSeconds(diff);

        if (ellapsedSeconds > MAX_DURATION)
            throw new IllegalStateException(MessageFormat.format("EstimatedProgress = {0}; CanceledAt = {1}", args.getEstimatedProgress(), canceledAt));
    }

    /// <summary>
    /// Date and time when document loading is started.
    /// </summary>
    private Date mLoadingStartedAt;

    /// <summary>
    /// Maximum allowed duration in sec.
    /// </summary>
    private static final double MAX_DURATION = 0.5;
}

Property Getters/Setters Summary
doublegetEstimatedProgress()
           Overall estimated percentage progress.
 

Property Getters/Setters Detail

getEstimatedProgress

public double getEstimatedProgress()
Overall estimated percentage progress.

Example:

Shows how to notify the user if document loading exceeded expected loading time.
public void progressCallback() throws Exception
{
    LoadingProgressCallback progressCallback = new LoadingProgressCallback();

    LoadOptions loadOptions = new LoadOptions(); { loadOptions.setProgressCallback(progressCallback); }

    try
    {
        new Document(getMyDir() + "Big document.docx", loadOptions);
    }
    catch (IllegalStateException exception)
    {
        System.out.println(exception.getMessage());
        // Handle loading duration issue.
    }
}

/// <summary>
/// Cancel a document loading after the "MaxDuration" seconds.
/// </summary>
public static class LoadingProgressCallback implements IDocumentLoadingCallback
{
    /// <summary>
    /// Ctr.
    /// </summary>
    public LoadingProgressCallback()
    {
        mLoadingStartedAt = new Date();
    }

    /// <summary>
    /// Callback method which called during document loading.
    /// </summary>
    /// <param name="args">Loading arguments.</param>
    public void notify(DocumentLoadingArgs args)
    {
        Date canceledAt = new Date();
        long diff = canceledAt.getTime() - mLoadingStartedAt.getTime();
        long ellapsedSeconds = TimeUnit.MILLISECONDS.toSeconds(diff);

        if (ellapsedSeconds > MAX_DURATION)
            throw new IllegalStateException(MessageFormat.format("EstimatedProgress = {0}; CanceledAt = {1}", args.getEstimatedProgress(), canceledAt));
    }

    /// <summary>
    /// Date and time when document loading is started.
    /// </summary>
    private Date mLoadingStartedAt;

    /// <summary>
    /// Maximum allowed duration in sec.
    /// </summary>
    private static final double MAX_DURATION = 0.5;
}

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