All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.xfa.LogMessageHandler Maven / Gradle / Ivy

There is a newer version: 2024.11.18751.20241128T090041Z-241100
Show newest version
/*
 * ADOBE CONFIDENTIAL
 *
 * Copyright 2005 Adobe Systems Incorporated All Rights Reserved.
 *
 * NOTICE: All information contained herein is, and remains the property of
 * Adobe Systems Incorporated and its suppliers, if any. The intellectual and
 * technical concepts contained herein are proprietary to Adobe Systems
 * Incorporated and its suppliers and may be covered by U.S. and Foreign
 * Patents, patents in process, and are protected by trade secret or copyright
 * law. Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained from
 * Adobe Systems Incorporated.
 */

package com.adobe.xfa;

import java.util.ArrayList;
import java.util.List;

/**
 * LogMessageHandler base class. All message handlers
 * will derive from this class. 
 * Class LogMessageHandler will eventually will support message filtering by Id.
 *
 * @exclude from published api -- Mike Tardif, May 2006.
 */

public abstract class LogMessageHandler {
	//int mnProcessId;

	private final long mlThreadId;

	private int mnThreshold;

	private final List moMessages = new ArrayList(); // cache all messages

	private String msAppContext;

	//private LogMessage msEmptyMessage;
	
	
	public LogMessageHandler() {
		mlThreadId = java.lang.Thread.currentThread().getId();
	}

	/**
	 * Retrieve a message based on its index.
	 * where 0 <= index < size()
	 * 

- only valid for handlers that return true for the * supportsRead method. * * @param nIndex - index into the collection * @return a LogMessageobject */ public LogMessage get(int nIndex) { return moMessages.get(nIndex); } /** * Clears out message buffer(s) */ public void clearMessages() { // do nothing } protected String getAppContext() { return msAppContext; } protected List getMessages() { return moMessages; } // /** // * Retrieve the messagehandler's process id // * @return a pid // */ // public int getProcessId() { // throw new ExFull(ResId.UNSUPPORTED_OPERATION, "LogMessageHandler#getProcessID"); // } /** * Retrieve the messagehandler's thread id * @return a threadId */ public long getThreadId() { return mlThreadId; } public int getThreshold() { return mnThreshold; } /** * Pure virtual function. Implemented in derived classes to handle message * output. *

if you want to cache messages, then the derived implementation * of this method should add the following lines: * * LogMessage poMessage = new LogMessage(oMessage); * getMessages().append(poMessage); * * * @param oMessage - the message to send */ abstract public void sendMessage(LogMessage oMessage); protected void setAppContext(String sAppContext) { msAppContext = sAppContext; } public void setThreshold(int nThreshold) { mnThreshold = nThreshold; } abstract public void flush(); /** * Retrieve the number of LogMessageobjects are in the collection. *

only valid for handlers that return true for the * supportsRead method. * @return - the number of LogMessageobjects in the collection */ public int size() { return moMessages.size(); } /** * Check whether the handler supports read operations. * If this class' supportsRead() method returns true, then * the messageHandler is capable of caching all of it's messages. These * messages can be accessed via operator[]. The * size() method can be used to find out the number of * messages cached. */ public boolean supportsRead() { return false; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy