File: ReferencialFileValidatorExtension.java

package info (click to toggle)
eclipse-wtp 3.35-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,860 kB
  • sloc: java: 215,049; xml: 3,946; sh: 70; makefile: 9
file content (88 lines) | stat: -rw-r--r-- 2,551 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*******************************************************************************
 * Copyright (c) 2001, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
/*
 * Created on May 3, 2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.eclipse.wst.validation.internal;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.wst.validation.internal.operations.ReferencialFileValidator;
import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;

/**
 * @author vijayb
 */
public class ReferencialFileValidatorExtension {
	private String id = null;
	private ReferencialFileValidator instance;
	private boolean errorCondition = false;
	private IConfigurationElement element;
	
	/** referencialFileValidator */
	public static final String REF_FILE_VALIDATOR_EXTENSION = "referencialFileValidator"; //$NON-NLS-1$
	
	/** run */
	public static final String RUN = "run"; //$NON-NLS-1$
	
	/** id */
	public static final String ATT_ID = "id"; //$NON-NLS-1$
	
	/** class */
	public static final String ATT_CLASS = "class"; //$NON-NLS-1$

	public ReferencialFileValidatorExtension() {
		super();
	}

	public ReferencialFileValidator getInstance() {
		try {
			if (instance == null && !errorCondition)
				instance = (ReferencialFileValidator) element.createExecutableExtension(RUN);
		} catch (Exception e) {
			ValidationPlugin.getPlugin().handleException(e);
			errorCondition = true;
		}
		return instance;
	}

	public ReferencialFileValidatorExtension(IConfigurationElement element) {
		if(!REF_FILE_VALIDATOR_EXTENSION.equals(element.getName()))
			throw new IllegalArgumentException("Extensions must be of the type \"" + REF_FILE_VALIDATOR_EXTENSION + "\"."); //$NON-NLS-1$ //$NON-NLS-2$
		this.element = element;
		init();
	}

	private void init() {
		this.id = this.element.getAttribute(ATT_ID);
	}

	/**
	 * @return Returns the id.
	 */
	public String getId() {
		return id;
	}
	
	public IConfigurationElement getElement() {
		return element;
	}

	/**
	 * @param id
	 *            The id to set.
	 */
	public void setId(String id) {
		this.id = id;
	}
}