c8e430c942af47da0eacdfa5dea9edaa1ca76da2
1 /*******************************************************************************
2 * Copyright (c) 2013 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Matthew Khouzam - Initial API and implementation
11 * Bernd Hufmann - Handling of directory traces types
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.core
.project
.model
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TraceValidationStatus
;
21 * TraceTypeHelper, a helper that can link a few names to a configuration element
24 * @author Matthew Khouzam
27 public class TraceTypeHelper
{
29 private final String fName
;
30 private final String fCategoryName
;
31 private final String fCanonicalName
;
32 private final ITmfTrace fTrace
;
33 private final boolean fIsDirectory
;
36 * Constructor for a trace type helper. It is a link between a canonical
37 * (hard to read) name, a category name, a name and a trace object. It is
38 * used for trace validation.
40 * @param canonicalName
41 * The "path" of the tracetype
43 * the category of the trace type
45 * the name of the trace
47 * an object of the trace type
49 * flag indicating whether the trace type is for a directory or file trace
51 public TraceTypeHelper(String canonicalName
, String categoryName
, String name
, ITmfTrace trace
, boolean isDir
) {
53 fCategoryName
= categoryName
;
54 fCanonicalName
= canonicalName
;
64 public String
getName() {
69 * Get the category name
71 * @return the category name
73 public String
getCategoryName() {
78 * Get the canonical name
80 * @return the canonical Name
82 public String
getCanonicalName() {
83 return fCanonicalName
;
87 * Is the trace of this type?
90 * the trace to validate
91 * @return whether it passes the validation
93 public boolean validate(String path
) {
94 boolean valid
= false;
96 valid
= standardValidate(path
);
102 * Validate a trace against this trace type with confidence level
105 * the trace to validate
106 * @return the confidence level (0 is lowest) or -1 if validation fails
109 public int validateWithConfidence(String path
) {
111 if (fTrace
!= null) {
112 IStatus status
= fTrace
.validate(null, path
);
115 if (status
instanceof TraceValidationStatus
) {
116 result
= ((TraceValidationStatus
) status
).getConfidence();
124 * Get an object of the trace type
125 * @return an object of the trace type
128 public ITmfTrace
getTrace() {
132 private boolean standardValidate(String path
) {
133 final boolean valid
= fTrace
.validate(null, path
).isOK();
138 * Get the class associated with this trace type
140 * @return The trace class
143 public Class
<?
extends ITmfTrace
> getTraceClass() {
144 return fTrace
.getClass();
148 * Returns whether trace type is for a directory trace or a single file trace
149 * @return <code>true</code> if trace type is for a directory trace else <code>false</code>
151 public boolean isDirectoryTraceType() {
157 public String
toString() {
This page took 0.034724 seconds and 5 git commands to generate.