Add a new method like createImagePage in the class WebPageWriter that will create a table where the first row has 4 columns of pictures. The second row would have the picture file names.
What will be an ideal response?
``` What are the four types of elements that can appear as part of an expression in Access? What will be an ideal response? The ____ is assigned based on the criticality of the component in the overall business process. A. RPO
B. RTO
C. SOW
D. SLA
? ?
? Method t o r e t u r n t h e s t r i n g f o r an HTML t a b l e
? from t h e p a s s e d l i s t w i t h t h e p a s s e d maximum columns
? @param f i l e N a m e s t h e a r r a y o f f i l e names
? @param maxCols t h e maximum number o f columns
? @return a s t r i n g w i t h t h e HTML t a g s f o r t h e t a b l e
?/
private S t r i n g makePictureTable ( S t r i n g [ ] f i l e N a m e s , i n t maxCols )
{
S t r i n g r e s u l t = ”
S t r i n g name = null ;
// g e t a l i s t o f p i c t u r e f i l e names from t h e s t r i n g i t e m s
L i s t nameList = g e t P i c t u r e F i l e N a m e s ( f i l e N a m e s ) ;
// g e t t h e number o f rows i n t h e t a b l e
i n t numRows = ( i n t ) Math . c e i l ( nameList . s i z e ( ) /
( double ) maxCols ) ;
// l o o p t h r o u g h t h e rows
f o r ( i n t row = 0 ; row < numRows ; row++)
{
r e s u l t = r e s u l t + ”
// l o o p t h r o u g h t h e columns and add t h e img s r c t a g s
f o r ( in t c o l = 0 ;
c o l < maxCols &&
( row ? maxCols + c o l ) < nameList . s i z e ( ) ;
c o l ++)
{
name = nameList . g e t ( row ? maxCols + c o l ) ;
r e s u l t = r e s u l t + ”” +
” td>” ;
}
r e s u l t = r e s u l t + ”
// l o o p t h r o u g h t h e columns and add t h e f i l e name
f o r ( in t c o l = 0 ;
c o l < maxCols &&
( row ? maxCols + c o l ) < nameList . s i z e ( ) ;
c o l ++)
{
name = nameList . g e t ( row ? maxCols + c o l ) ;
r e s u l t = r e s u l t + ”” + name + ” ” ;
}
r e s u l t = r e s u l t + ”
}
r e s u l t = r e s u l t + ” t a b l e >” ;
return r e s u l t ;
}
/? ?
? Method t o c r e a t e a page w i t h t h u m b n a i l s o f a l l t h e images
? i n a d i r e c t o r y i n a t a b l e w i t h t h e f i l e names under t h e
? thumbnails
? @param d i r e c t o r y t h e d i r e c t o r y t o c r e a t e t h e page f o r
?/
public void createImagePageV2 ( S t r i n g d i r e c t o r y )
{
S t r i n g name = null ;
S t r i n g body = ”
S t r i n g endOfLine = System . g e t P r o p e r t y ( ” l i n e . s e p a r a t o r ” ) ;
// t r y t h e f o l l o w i n g
try {
// c r e a t e t h e F i l e o b j e c t
F i l e d i r = new F i l e ( d i r e c t o r y ) ;
// g e t t h e f u l l p a t h name o f t h e d i r e c t o r y
S t r i n g pathName = d i r e c t o r y + d i r . getName ( ) + ” . html ” ;
BufferedWriter writer =
new B u f f e r e d W r i t e r (new F i l e W r i t e r ( pathName ) ) ;
// w r i t e t h e s t a r t
writeStart ( writer );
// w r i t e t h e head
writeHead ( w r i t e r , ” Thumbnails from ” + d i r e c t o r y ) ;
// g e t t h e a r r a y o f i t e m s i n t h e d i r e c t o r y
String [ ] items = d i r . l i s t ( ) ;
// g e t t h e s t r i n g f o r t h e t a b l e o f p i c t u r e s
body = makePictureTable ( items , 4 ) ;
// w r i t e t h e body
writeBody ( w r i t e r , body ) ;
// w r i t e t h e end
writeEnd ( w r i t e r ) ;
// c l o s e t h e w r i t e r
writer . close ( ) ;
} catch ( E x c e p t i o n ex ) {
ex . p r i n t S t a c k T r a c e ( ) ;
}
}
```
You might also like to view...