|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * Base class for source file updater objects |
|
17 * |
|
18 */ |
|
19 package com.nokia.tracebuilder.engine.source; |
|
20 |
|
21 import com.nokia.tracebuilder.source.SourceLocationBase; |
|
22 import com.nokia.tracebuilder.source.SourceParserException; |
|
23 |
|
24 /** |
|
25 * Base class for source file updater objects |
|
26 * |
|
27 */ |
|
28 public abstract class SourceEditorUpdater { |
|
29 |
|
30 /** |
|
31 * Source properties to update |
|
32 */ |
|
33 private SourceProperties properties; |
|
34 |
|
35 /** |
|
36 * Constructor |
|
37 * |
|
38 * @param properties |
|
39 * the source to updated |
|
40 */ |
|
41 protected SourceEditorUpdater(SourceProperties properties) { |
|
42 this.properties = properties; |
|
43 } |
|
44 |
|
45 /** |
|
46 * Updates the source |
|
47 */ |
|
48 public void update() { |
|
49 properties.getUpdateQueue().queueUpdate(this); |
|
50 } |
|
51 |
|
52 /** |
|
53 * Gets the source properties |
|
54 * |
|
55 * @return the source properties |
|
56 */ |
|
57 protected SourceProperties getSource() { |
|
58 return properties; |
|
59 } |
|
60 |
|
61 /** |
|
62 * Checks if this updater equals the given updater. Default implementation |
|
63 * compares the position references |
|
64 * |
|
65 * @param updater |
|
66 * the updater to be checked |
|
67 * @return true if the updates are equal |
|
68 */ |
|
69 protected boolean updaterEquals(SourceEditorUpdater updater) { |
|
70 return getPosition() == updater.getPosition(); |
|
71 } |
|
72 |
|
73 /** |
|
74 * Runs the update operation on the source |
|
75 * |
|
76 * @return true if source was updated, false if not |
|
77 * @throws SourceParserException |
|
78 * if source parser fails |
|
79 */ |
|
80 protected abstract boolean runUpdate() throws SourceParserException; |
|
81 |
|
82 /** |
|
83 * Gets the position where the update happens |
|
84 * |
|
85 * @return the update position |
|
86 */ |
|
87 protected abstract SourceLocationBase getPosition(); |
|
88 |
|
89 } |