⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractconditionaldirective.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/**
 * Copyright (c) 2003-2005 Craig Setera
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 */
package eclipseme.core.internal.preprocessor.directive;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.dom.Comment;

import eclipseme.core.internal.preprocessor.Directive;
import eclipseme.core.model.SymbolDefinitionSet;

/**
 * Abstract superclass of the conditional directives in
 * the system.
 * <p />
 * Copyright (c) 2003-2005 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.2 $
 * <br>
 * $Date: 2006/11/12 01:11:01 $
 * <br>
 * @author Craig Setera
 */
public abstract class AbstractConditionalDirective extends Directive {

	protected ExpressionEvaluator expressionEvaluator;

	/**
	 * Construct a new instance.
	 * 
	 * @param resource
	 * @param comment
	 * @param commentText
	 */
	public AbstractConditionalDirective(
		IResource resource,
		Comment comment, 
		String commentText) 
	{
		super(resource, comment, commentText);
	}
	
	/**
	 * @see eclipseme.core.internal.preprocessor.Directive#isConditionalDirective()
	 */
	public boolean isConditionalDirective() {
		return true;
	}

	/**
	 * Return a boolean indicating whether this directive is an if
	 * type of statement.
	 * 
	 * @return
	 */
	public boolean isElseDirective() {
		return false;
	}

	/**
	 * Return a boolean indicating whether or not this directive is
	 * enabled for the specified identifiers.
	 * 
	 * @param identifiers
	 * @param monitor TODO
	 * @return
	 */
	protected boolean isEnabled(SymbolDefinitionSet identifiers, IProgressMonitor monitor) {
		return false;
	}

	/**
	 * Return a boolean indicating whether this directive is enabled
	 * based on the arguments treated as an expression.
	 * 
	 * @param identifiers
	 * @param monitor
	 * @return
	 */
	protected boolean isEnabledByExpression(SymbolDefinitionSet identifiers, IProgressMonitor monitor) {
		if (expressionEvaluator == null) {
			expressionEvaluator = new ExpressionEvaluator(getDirectiveArguments());
		}
		
		return expressionEvaluator.evaluate(identifiers, monitor);
	}

	/**
	 * Return a boolean indicating whether this directive is enabled
	 * based on the specified identifier.
	 * 
	 * @param identifiers
	 * @param monitor
	 * @return
	 */
	protected boolean isEnabledByIdentifier(SymbolDefinitionSet identifiers, IProgressMonitor monitor) {
		String identifer = getDirectiveArguments();
		return identifiers.isDefined(identifer);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -