protected HeaderFooter(String s) {
if (s == null || s.length() == 0)
{
left = createContents();
right = createContents();
centre = createContents();
return;
}
int pos = 0;
int leftPos = s.indexOf(LEFT_ALIGN);
int rightPos = s.indexOf(RIGHT_ALIGN);
int centrePos = s.indexOf(CENTRE);
// Do the left position string
if (pos == leftPos)
{
if (centrePos != -1)
{
left = createContents(s.substring(pos + 2, centrePos));
pos = centrePos;
}
else if (rightPos != -1 )
{
left = createContents(s.substring(pos + 2, rightPos));
pos = rightPos;
}
else
{
left = createContents(s.substring(pos + 2));
pos = s.length();
}
}
// Do the centrally positioned part of the string. This is the default
// if no alignment string is specified
if (pos == centrePos ||
(leftPos == -1 && rightPos == -1 && centrePos == -1))
{
if (rightPos != -1)
{
centre = createContents(s.substring(pos + 2, rightPos));
pos = rightPos;
}
else
{
int cpos = (pos == centrePos) ? pos + 2 : pos;
centre = createContents(s.substring(cpos));
pos = s.length();
}
}
// Do the right positioned part of the string
if (pos == rightPos)
{
right = createContents(s.substring(pos + 2));
pos = s.length();
}
if (left == null)
{
left = createContents();
}
if (centre == null)
{
centre = createContents();
}
if (right == null)
{
right = createContents();
}
}
Constructor used when reading workbooks to separate the left, right
a central part of the strings into their constituent parts |