CharacterIDGenerator.java 1.65 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.internal.pdftoolkit.core.exceptions.PDFUnableToCompleteOperationException
 */
package com.adobe.internal.pdftoolkit.pdf.content.processor;

import com.adobe.internal.pdftoolkit.core.exceptions.PDFUnableToCompleteOperationException;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.document.listener.DocumentListener;
import com.adobe.internal.pdftoolkit.pdf.document.listener.DocumentListenerProperties;
import com.adobe.internal.pdftoolkit.pdf.document.listener.DocumentListenerRegistry;
import com.adobe.internal.pdftoolkit.pdf.document.listener.DocumentMessage;

public class CharacterIDGenerator
implements DocumentListener {
    private long count = 0;

    private CharacterIDGenerator() {
    }

    public static CharacterIDGenerator getInstance(PDFDocument document) {
        DocumentListener existingListener = document.getListenerRegistry().getListener(CharacterIDGenerator.class);
        if (existingListener == null) {
            CharacterIDGenerator idGenerator = new CharacterIDGenerator();
            document.getListenerRegistry().registerListener(CharacterIDGenerator.class, idGenerator);
            return idGenerator;
        }
        return (CharacterIDGenerator)existingListener;
    }

    public void message(DocumentMessage message) throws PDFUnableToCompleteOperationException {
    }

    public DocumentListenerProperties getProperties() {
        return null;
    }

    public long getNewCharacterID() {
        return this.count++;
    }

    public void resetCharacterID() {
        this.count = 0;
    }
}