buildframework/helium/sf/java/legacy/src/com/nokia/ant/taskdefs/ModelPropertiesTask.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
* All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
* This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
* which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
* Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
* Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
* Description: 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
*/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
package com.nokia.ant.taskdefs;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
import java.io.File;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
import java.io.IOException;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    22
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
import org.apache.tools.ant.BuildException;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    24
import org.apache.tools.ant.Project;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import org.apache.tools.ant.Task;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
import org.dom4j.DocumentException;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import com.nokia.ant.ModelPropertiesParser;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
/**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
 * Renders model property and group description to Wiki Model Syntax.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
 * Usage: <hlm:parsemodel output="Output file path" input="Input file path"/>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
 * @ant.task name="parsemodel"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
public class ModelPropertiesTask extends Task
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
{
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
    private File outputFile;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
    private File inputFile;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
    public ModelPropertiesTask()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
    {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        setTaskName("ModelPropertiesTask");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
    public void setOutput(File outputFile)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
    {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        this.outputFile = outputFile;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
    public void setInput(File inputFile)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
    {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
        this.inputFile = inputFile;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
     * Executes ModelPropertyParser
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
     * @throws BuildException
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
     */    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
    public void execute()
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
    {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
        log("Parsing model properties", Project.MSG_DEBUG);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
        try
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
        {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
            ModelPropertiesParser pmp = new ModelPropertiesParser(inputFile, outputFile);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
            pmp.parsePropertiesDescription();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
        catch (IOException ioe)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
        {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
            throw new BuildException("Couldn't find model file: " + ioe.getMessage());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
        catch (DocumentException be)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
        {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    75
            throw new BuildException("Error in creating model dom object: " + be.getMessage());
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    78
}