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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
;
17 import org
.eclipse
.core
.runtime
.Status
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
21 * TraceTypeHelper, a helper that can link a few names to a configuation 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
;
35 * Constructor for a trace type helper. It is a link between a canonical
36 * (hard to read) name, a category name, a name and a trace object. It is
37 * used for trace validation.
39 * @param canonicalName
40 * The "path" of the tracetype
42 * the category of the trace type
44 * the name of the trace
46 * an object of the trace type
48 public TraceTypeHelper(String canonicalName
, String categoryName
, String name
, ITmfTrace trace
) {
50 fCategoryName
= categoryName
;
51 fCanonicalName
= canonicalName
;
60 public String
getName() {
65 * Get the category name
67 * @return the category name
69 public String
getCategoryName() {
74 * Get the canonical name
76 * @return the canonical Name
78 public String
getCanonicalName() {
79 return fCanonicalName
;
83 * Is the trace of this type?
86 * the trace to validate
87 * @return whether it passes the validation
89 public boolean validate(String path
) {
90 boolean valid
= false;
92 valid
= standardValidate(path
);
93 } else if (fCategoryName
.equals(TmfTraceType
.CUSTOM_TXT_CATEGORY
) || fCategoryName
.equals(TmfTraceType
.CUSTOM_XML_CATEGORY
)) {
94 valid
= customValidate(path
);
99 private boolean standardValidate(String path
) {
100 final boolean valid
= fTrace
.validate(null, path
).equals(Status
.OK_STATUS
);
104 private static boolean customValidate(String path
) {
105 File f
= new File(path
);
106 return f
.exists() && f
.isFile();
110 public String
toString() {
This page took 0.032772 seconds and 5 git commands to generate.