001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.modules.php.dbgp.packets;
042:
043: /**
044: * @author ads
045: *
046: */
047: public abstract class PropertyCommand extends DbgpCommand {
048:
049: private static final String NAME_ARG = "-n "; // NOI18N
050:
051: private static final String MAX_SIZE_ARG = "-m "; // NOI18N
052:
053: private static final String CONTEXT_ARG = "-c "; // NOI18N
054:
055: private static final String DEPTH_ARG = "-d "; // NOI18N
056:
057: private static final String PAGE_ARG = "-p "; // NOI18N
058:
059: PropertyCommand(String command, String transactionId) {
060: super (command, transactionId);
061: myDepth = -1;
062: myContext = -1;
063: mySize = -1;
064: myPage = -1;
065: }
066:
067: public void setStackDepth(int depth) {
068: myDepth = depth;
069: }
070:
071: public void setContext(int id) {
072: myContext = id;
073: }
074:
075: public void setName(String name) {
076: myName = name;
077: }
078:
079: public void setMaxDataSize(int size) {
080: mySize = size;
081: }
082:
083: public void setDataPage(int page) {
084: myPage = page;
085: }
086:
087: protected String getName() {
088: return myName;
089: }
090:
091: protected int getContext() {
092: return myContext;
093: }
094:
095: @Override
096: protected String getArguments() {
097: StringBuilder builder = new StringBuilder(NAME_ARG);
098: builder.append(myName);
099:
100: setDepth(builder);
101: setContext(builder);
102: setMaxSize(builder);
103: setPage(builder);
104:
105: return builder.toString();
106: }
107:
108: private void setPage(StringBuilder builder) {
109: if (myPage == -1) {
110: return;
111: }
112: builder.append(BrkpntSetCommand.SPACE);
113: builder.append(PAGE_ARG);
114: builder.append(myPage);
115: }
116:
117: private void setMaxSize(StringBuilder builder) {
118: if (mySize == -1) {
119: return;
120: }
121: builder.append(BrkpntSetCommand.SPACE);
122: builder.append(MAX_SIZE_ARG);
123: builder.append(mySize);
124: }
125:
126: private void setContext(StringBuilder builder) {
127: if (myContext == -1) {
128: return;
129: }
130: builder.append(BrkpntSetCommand.SPACE);
131: builder.append(CONTEXT_ARG);
132: builder.append(myContext);
133: }
134:
135: private void setDepth(StringBuilder builder) {
136: if (myDepth == -1) {
137: return;
138: }
139: builder.append(BrkpntSetCommand.SPACE);
140: builder.append(DEPTH_ARG);
141: builder.append(myDepth);
142: }
143:
144: private int myPage;
145:
146: private int myContext;
147:
148: private int myDepth;
149:
150: private String myName;
151:
152: private int mySize;
153:
154: }
|