Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alignment API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
moex
Alignment API
Commits
45e3ff33
Commit
45e3ff33
authored
14 years ago
by
Jérôme Euzenat
Browse files
Options
Downloads
Patches
Plain Diff
- The base class for having all rendrerers indented
parent
1371b59e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fr/inrialpes/exmo/align/impl/renderer/IndentedRendererVisitor.java
+111
-0
111 additions, 0 deletions
...pes/exmo/align/impl/renderer/IndentedRendererVisitor.java
with
111 additions
and
0 deletions
src/fr/inrialpes/exmo/align/impl/renderer/IndentedRendererVisitor.java
0 → 100644
+
111
−
0
View file @
45e3ff33
/*
* $Id$
*
* Copyright (C) INRIA, 2010
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
fr.inrialpes.exmo.align.impl.renderer
;
import
java.util.Enumeration
;
import
java.util.Hashtable
;
import
java.util.Set
;
import
java.util.HashSet
;
import
java.util.Properties
;
import
java.io.PrintWriter
;
import
java.net.URI
;
/**
* Structure for indented rendering
*
* @author Jérôme Euzenat
* @version $Id$
*/
public
class
IndentedRendererVisitor
{
PrintWriter
writer
=
null
;
protected
String
INDENT
=
" "
;
protected
String
NL
=
""
;
/** String for the pretty linebreak. **/
protected
String
linePrefix
=
""
;
private
int
prefixCount
=
0
;
public
IndentedRendererVisitor
(
PrintWriter
writer
){
NL
=
System
.
getProperty
(
"line.separator"
);
this
.
writer
=
writer
;
}
public
void
setIndentString
(
String
ind
)
{
INDENT
=
ind
;
}
public
void
setNewLineString
(
String
nl
)
{
NL
=
nl
;
}
// ===================================================================
// pretty printing management
// JE: I THINK THAT THIS IS CONVENIENT BUT INDUCES A SERIOUS LAG IN
// PERFORMANCES (BOTH VERSIONS v1 and v2)
// LET SEE IF THERE IS NO WAY TO DO THIS DIRECTLY IN THE WRITER !!!
/**
* Increases the lineprefix by one INDENT
*/
protected
void
increaseIndent
()
{
prefixCount
++;
}
/**
* Decreases the lineprefix by one INDENT
*/
protected
void
decreaseIndent
()
{
if
(
prefixCount
>
0
)
{
prefixCount
--;
}
}
// JE: I would like to see benchmarks showing that this is more efficient
// than adding them to buffer directly each time
private
void
calcPrefix
()
{
StringBuilder
buffer
=
new
StringBuilder
();
buffer
.
append
(
NL
);
for
(
int
i
=
0
;
i
<
prefixCount
;
i
++)
{
buffer
.
append
(
INDENT
);
}
linePrefix
=
buffer
.
toString
();
}
protected
void
indentedOutputln
(
String
s
){
for
(
int
i
=
0
;
i
<
prefixCount
;
i
++)
writer
.
print
(
INDENT
);
writer
.
print
(
s
+
NL
);
}
protected
void
indentedOutput
(
String
s
){
for
(
int
i
=
0
;
i
<
prefixCount
;
i
++)
writer
.
print
(
INDENT
);
writer
.
print
(
s
);
}
protected
void
indentedOutputln
(){
for
(
int
i
=
0
;
i
<
prefixCount
;
i
++)
writer
.
print
(
INDENT
);
}
protected
void
indentedOutput
(){
for
(
int
i
=
0
;
i
<
prefixCount
;
i
++)
writer
.
print
(
INDENT
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment